Create circle in iOS Objective C with and without fill
Solution:
In iOS you can create a circle using CGContextref. The below code is used for draw a circle in a view with 0 x axis,0 y axis,width 20 and height 20..
In iOS you can create a circle using CGContextref. The below code is used for draw a circle in a view with 0 x axis,0 y axis,width 20 and height 20..
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGRect rect = CGRectMake(0, 0,20,20)
    CGContextClearRect(ctx, rect);
    CGContextSetLineWidth(ctx, 10);
CGContextStrokeEllipseInRect(UIGraphicsGetCurrentContext(), rect);
CGContextStrokeEllipseInRect(UIGraphicsGetCurrentContext(), rect);
If you want to fill the rectangle then add the below code 
        CGContextSetFillColorWithColor(ctx, color.CGColor);
CGContextFillEllipseInRect(UIGraphicsGetCurrentContext(), rect);
CGContextFillEllipseInRect(UIGraphicsGetCurrentContext(), rect);
Comments
Post a Comment