I have setup a UIView
using constraints in a storyboard, and I want to add a circle progress to this view using CAShapeLayer
with a UIBezierPath
.
I have added this correctly, but the circle isn't expanded to all the view. i call this in my viewDidLoad function. My view has constraints to asjust height top-x view and width.
- (void)viewDidLoad {
[super viewDidLoad];
CAShapeLayer *borderLayer = [CAShapeLayer layer];
borderLayer.fillColor = [UIColor whiteColor].CGColor;
CGFloat lineWidth = 4;
CGRect rect = CGRectMake(lineWidth+lineWidth/2, lineWidth+lineWidth/2, self.myView.bounds.size.width/2, self.myView.bounds.size.height/2);
borderLayer.path = [UIBezierPath bezierPathWithOvalInRect:rect].CGPath;
borderLayer.strokeColor = [[UIColor redColor] CGColor];
borderLayer.lineWidth = lineWidth;
[borderLayer setFillColor:[UIColor clearColor].CGColor];
[self.myView.layer addSublayer:borderLayer];
}
The circle progress isn't resized to the UIView
, and it is shown like this:
How can I draw this occupying the whole UIView
like this: