I am trying to make rounded corners for my views and fencing a strange problem.
I use the following code to make rounded corners for my view
bezierPath = [UIBezierPath bezierPathWithRoundedRect:btnView.bounds
byRoundingCorners:UIRectCornerAllCorners
cornerRadii:radius];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = btnView.bounds;
maskLayer.path = bezierPath.CGPath;
btnView.layer.mask = maskLayer;
The problem is, it is not working for bottom corners. If I use UIRectCornerBottomLeft
nothing happens, if I use UIRectCornerAllCorners
only top corners are rounded.
EDIT: I dont use layer.cornerRadius because I just want to round bottom corners.
It turned out I do not have problem, if I remove UIViewAutoresizingFlexibleHeight
autoresizing mask from my view. But I would like to use autoresizing mask. Is it possible if yes how?
I have already tried setting autoresizingMask before and after setting the mask of the layer. No luck!
I have just had a similar problem that's taken hours to solve - the answer was very simple: move my code from viewDidLoad to viewDidLayoutSubviews: this is the first method called after autolayout has completed .... so I suspect I did have 4 rounded corners but somehow they were off the edge of the screen.
I think you should use
bezierPath.lineCapStyle = CGLineCap.Round
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With