Search code examples
iosobjective-cprogress

Objective-C: Circular progress view


How to make progressView like in app store with using default progresView?

As image shown below:

enter image description here


Solution

  • You can use this code, I have drew the circle for you.

    - (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    CAShapeLayer* outsideShapeLayer = [[CAShapeLayer alloc] init];
    outsideShapeLayer.fillColor = [[UIColor clearColor] CGColor];
    outsideShapeLayer.frame = CGRectMake(100, 100, 100, 100);
    outsideShapeLayer.path = [[UIBezierPath bezierPathWithOvalInRect:outsideShapeLayer.bounds] CGPath];
    outsideShapeLayer.lineWidth = 1;
    outsideShapeLayer.strokeColor = [[UIColor blueColor] CGColor];
    [self.view.layer addSublayer:outsideShapeLayer];
    
    
    CAShapeLayer* shapeLayer = [[CAShapeLayer alloc] init];
    shapeLayer.fillColor = [[UIColor clearColor] CGColor];
    shapeLayer.frame = CGRectMake(102.5, 102.5, 95, 95);
    shapeLayer.path = [[UIBezierPath bezierPathWithOvalInRect:shapeLayer.bounds] CGPath];
    shapeLayer.lineWidth = 5;
    shapeLayer.strokeColor = [[UIColor blueColor] CGColor];
    shapeLayer.strokeStart = 0;
    shapeLayer.strokeEnd = 0.75f;
    [self.view.layer addSublayer:shapeLayer];
    }
    

    Hope it can help you.