How can I make a line with the ends rounded? I'm drawing a simple straight line as follows, but cannot get the ends round. ".cornerRadius" doesn't work. Any ideas?
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)
}
}
Try replacing:
.stroke(lineWidth: 8.0)
with:
.stroke(style: StrokeStyle(lineWidth: 8.0, lineCap: .round))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.