I am trying to round only the top right and left corners of my tableview. I am using the code below and it only seems to be rounding the top left corner...
CAShapeLayer *topLayer = [CAShapeLayer layer];
UIBezierPath *roundedPath =
[UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(9.f, 9.0f)];
topLayer.path = [roundedPath CGPath];
Hope this will work. Find the top corner paths to create a mask layer
UIBezierPath *PathToMask;
PathToMask = [UIBezierPath bezierPathWithRoundedRect:self.testView.bounds
byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
cornerRadii:CGSizeMake(8.0, 8.0)];
Create a shape layer mask using the UIBezierPath maskPath
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame =self.testView.bounds;
maskLayer.path = PathToMask.CGPath;
set the mask layer maskLayer
self.testView.layer.mask = maskLayer;
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