Reputation: 381
I want to draw a layer on a view. for that i write this code.
arcLayer=[CAShapeLayer layer];
arcLayer.frame=self.circleView.frame;
arcLayer.backgroundColor = [UIColor purpleColor].CGColor;
[self.circleView.layer addSublayer:arcLayer];
but this the position of layer is not exact on the view as you can see in the following image. the green one is circleView and the purple one is arc layer.
Upvotes: 0
Views: 2874
Reputation: 11770
You have a problem on this line: arcLayer.frame=self.circleView.frame;
. Change that line to:
CGRect frame = self.circleView.frame;
frame.origin = CGPointZero;
arcLayer.frame=frame;
This will solve your problem. You just forgot to set origin of your layer to CGPointZero
or whatever position
.
Good Luck!
Upvotes: 3