I have implemented a circular stroke as you can see in the picture below (of course without the numbers ).
Unfortunately, I encounter two problems that you may be able to help me with.
I want the gradient to go along the line, i.e. the darkest point in this picture should always be at the end of the stroke (1b) and not as currently at (1a)
Is it possible to give a stroke a lineCap
.round
on one side and a lineCap.butt
on the other side? I would like to have a rounded line end at (1b) and a straight line at (2), which corresponds to .butt.
Here is my example code
struct CircularGradientLine: View {
private let gradient = LinearGradient(
gradient: Gradient(colors: [StyleGuide.Color.primary, .white]),
startPoint: .leading,
endPoint: .trailing)
public var body: some View {
ZStack {
Circle()
.stroke(Color.white, lineWidth: 46)
Circle()
.trim(from: 0, to: CGFloat(0.8))
.stroke(gradient, style:
StrokeStyle(lineWidth: 46,
lineCap: .round))
}.padding(60)
}
}
I would be delighted if someone could help me there