Custom strokeStyle lineCap with corner radius [duplicate]

1 week ago 11
ARTICLE AD BOX

If you want to keep using Circle().stroke() but just want smoother corners, you can overlay small circles at the endpoints:

ZStack { Circle() .trim(from: CGFloat(start + offset), to: CGFloat(end - offset)) .stroke(color, style: StrokeStyle(lineWidth: ringWidth, lineCap: .butt)) // Add rounded caps manually Circle() .fill(color) .frame(width: ringWidth, height: ringWidth) .offset(x: /* calculate position for start */) Circle() .fill(color) .frame(width: ringWidth, height: ringWidth) .offset(x: /* calculate position for end */) }
Read Entire Article