Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make corner for Arc

I have made an arc like below. By specifying the Radius, Start angle, End angle

    CGContextAddArc(ctx, self.frame.size.width/2  , self.frame.size.height/2,
 self.radius, 2*M_PI, 3*M_PI/2-ToRad(angle), 0);

Now i want to make the corner of arch rounded. So need of drawing circles on the both ends. Because I'm using frame dimensions giving constants wont work.

enter image description here

like image 535
Saranjith Avatar asked Dec 29 '16 07:12

Saranjith


1 Answers

You can set it easily by

Objective-C

CGContextSetLineCap(context, kCGLineCapRound);

Swift

context?.setLineCap(.round)
context?.addArc(center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true/false)
like image 175
Terence Avatar answered Oct 12 '22 09:10

Terence