I have difficulty to use strokeBorder after trim in SwiftUI, how can do this?
Circle()
.trim(from: 0, to: 0.5)
.strokeBorder(Color.red, style: StrokeStyle(lineWidth: 50.0, lineCap: .round, lineJoin: .round))
Error:
Value of type 'some Shape' has no member 'strokeBorder'
⚠️ There are at least 2 other ways to get the result like strokeBorder gives. But they are NOT using strokeBorder, I want to solve the issue while using strokeBorder.
This still seems to be a problem, so maybe it's not a bug to be fixed. I used the same solution suggested by aheze, but having the lineWidth as a variable or constant helps, especially if there are additional layers that need to be added. For instance, any additional Shapes/Images that need to layered on top would also need to have this additional padding to keep things aligned.
let lineWidth: CGFloat = 50.0
Circle()
.trim(from: 0, to: 0.5)
.stroke(Color.red, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round, lineJoin: .round))
.padding(lineWidth / 2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With