[IOS] How to draw a circle

Reference: http://blog.csdn.net/u013282507/article/details/50247001

 

-(void)initCircle{
    CAShapeLayer *layer = [CAShapeLayer new];
    layer.lineWidth = 2;
    // color of the ring
    layer.strokeColor = [UIColor blackColor].CGColor;
    //background fill color
    layer.fillColor = [UIColor clearColor].CGColor;
    // set the radius to 10
    CGFloat radius = circle_radius;
    // follow the clockwise direction
    BOOL clockWise = false;
    //initialize a path
    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:self.view.center radius:radius startAngle:0 endAngle:2.0f*M_PI clockwise:clockWise];
    layer.path = [path CGPath];
    [self.view.layer addSublayer:layer];
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326073925&siteId=291194637
Recommended