Skip to content

Instantly share code, notes, and snippets.

@luxinyan
Last active August 29, 2015 14:05
Show Gist options
  • Save luxinyan/b5f7365ee15ca97eacd6 to your computer and use it in GitHub Desktop.
Save luxinyan/b5f7365ee15ca97eacd6 to your computer and use it in GitHub Desktop.
How to use UIBezierPath draw
//Begin the path
UIBezierPath *path = [[UIBezierPath alloc] init];
//Move around, add lines or arcs to the path
[path moveToPoint:CGPointMake(75, 10)];
[path addLineToPoint:CGPointMake(160, 150)];
[path addLineToPoint:CGPointMake(10, 150]);
//Close the path
[path closePath];
//stroke/fill it
[[UIColor greenColor] setFill];
[[UIColor redColor] setStroke];
//draw
[path fill]; [path stroke];
//set linde width
path.lineWidth = 2.0;
//draw round rectangle
UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:(CGRect)bounds cornerRadius:(CGFloat)radius];
//draw oval
UIBezierPath *oval = [UIBezierPath bezierPathWithOvalInRect:(CGRect)bounds];
//clip
[roundedRect addClip];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment