Skip to content

Instantly share code, notes, and snippets.

@fbparis
Created April 1, 2014 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbparis/9907321 to your computer and use it in GitHub Desktop.
Save fbparis/9907321 to your computer and use it in GitHub Desktop.
UIBezierPath *path =[UIBezierPath bezierPath];
CGPoint center = CGPointMake(rect.size.width / 2.0, rect.size.height / 2.0);
CGFloat radius = sqrt(pow(center.x, 2) + pow(center.y, 2));
CGFloat angle = M_PI / self.count;
[self.color set];
[path moveToPoint:center];
for (NSUInteger i = 0; i < self.count; i++) {
[path addArcWithCenter:center radius:radius startAngle:2*i*angle endAngle:(2*i+1)*angle clockwise:YES];
[path addLineToPoint:center];
[path closePath];
[path fill];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment