15

I'm trying to draw a circle using UIBezierPath(ovalInRect: CGRectMake()). Then I'll change the strokeEnd property. When this happens, either end of the circular line have sharp corners. Is there any way to round out these corners?

enter image description here(I would like to make the beginning and end of this line curved)

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Matt Spoon
  • 2,760
  • 5
  • 25
  • 41

2 Answers2

37

Assuming you are using a CAShapeLayer to draw this, just set the lineCap, e.g.:

layer.lineCap = .round
Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • Please would you take a look at this for me http://stackoverflow.com/questions/44062346/how-to-create-a-circle-with-rounded-ends-for-each-quadrant. I've been trying to solve it for a while – Hilarious404 May 19 '17 at 12:08
3

For drawRect based solutions use lineCapStyle

let path = UIBezierPath(...) path.lineCapStyle = .round

Lee Irvine
  • 3,057
  • 1
  • 15
  • 12