如何使两端的线圆角?我正在画一条简单的直线,如下所示,但无法使两端圆圆。 “.cornerRadius”不起作用。有任何想法吗?
struct Line: View {
let geoProx: GeometryProxy
var body: some View {
Path{ path in
path.move(to: CGPoint(x: geoProx.size.width/2, y: geoProx.size.height/2))
path.addLine(to: CGPoint(x: geoProx.size.width/2 - geoProx.size.width/4, y: geoProx.size.height/2))
}
.stroke(lineWidth: 8.0)
.foregroundColor(.white)
.cornerRadius(10.0)
.zIndex(1.5)
}
}
最佳答案
尝试更换:
.stroke(lineWidth: 8.0)
和:
.stroke(style: StrokeStyle(lineWidth: 8.0, lineCap: .round))