Categories
ios iphone swift swiftui

Round Corner of Path Line SwiftUI

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)
}
}