Tutorial by Examples

Corner radius for all 4 edges: UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) cornerRadius: 11]; [UIColor.grayColor setFill]; [rectanglePath fill]; Corner radius for top-left edge: UIBezierPath* rectanglePath = [UIBezierPath bezierPat...
For a simple circle: UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(0,0,50,50)]; [UIColor.grayColor setFill]; [ovalPath fill]; Swift: let ovalPath = UIBezierPath(ovalInRect: CGRect(x: 0, y: 0, width: 50, height: 50)) UIColor.grayColor().setFill() ovalPath.fill...
For bezier path to get resized based on the view frame, override the drawRect of view that you are drawing the bezier path : - (void)drawRect:(CGRect)frame { UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame), CGRectGetWidth(f...
Consider a simple rectangle that is drawn by the bezier path. UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: CGRectMake(x,y,width,height)]; [UIColor.grayColor setFill]; [rectanglePath fill]; Basic Outer-fill shadow: CGContextRef context = UIGraphicsGetCurrentContext();...
This example shows the process from designing the shape you want to drawing it on a view. A specific shap is used but the concepts you learn can be applied to any shape. How to draw a Bézier path in a custom view These are the main steps: Design the outline of the shape you want. Divide the ou...
pie view - (void)drawRect:(CGRect)rect { NSArray *data = @[@30, @15, @5, @17, @3, @10, @20]; // 1. context CGContextRef cxtRef = UIGraphicsGetCurrentContext(); CGPoint center = CGPointMake(150, 150); CGFloat radius = 150; __block CGFloat startAngle = 0; ...

Page 1 of 1