Last active
August 29, 2015 14:05
-
-
Save luxinyan/b5f7365ee15ca97eacd6 to your computer and use it in GitHub Desktop.
How to use UIBezierPath draw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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