像这样

你知道怎么做这样的虚线吗?
宽度必须是全长。
发布于 2020-09-08 05:48:56
你可以用以下方法划出这样一条线:
GeometryReader { geometry in
VStack {
Path{ path in
path.move(to: CGPoint(x: 0, y: geometry.size.height / 2))
path.addLine(to: CGPoint(x: geometry.size.width, y: geometry.size.height / 2))
}
.stroke(style: StrokeStyle( lineWidth: 2, dash: [5]))
.foregroundColor(Color(UIColor.blue))
}
}这一行将例如在屏幕的中间。只需调整y参数以移动这条线。
结果:

https://stackoverflow.com/questions/63787548
复制相似问题