How to merge only corners in a UITableView?

I am trying to round only the top right and left corners of my table. I use the code below and it only rounds 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];
+5
source share
1 answer

Hope this works. 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 mask

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 
maskLayer.frame =self.testView.bounds;
maskLayer.path = PathToMask.CGPath;

set layer mask maskLayer

self.testView.layer.mask = maskLayer;
+2
source

All Articles