UIView in cell - cannot round right corners

I have a rectangular object UIViewin a cell with a static table. I have access to the object, and I'm trying to selectively bypass the corners, but it will not be around the corners on the right. Here's what it looks like in a storyboard:

enter image description here

The view I want to customize is pale yellow. The red view does not serve any real purpose, except to confirm that the other view is not cropped.

No problems with limitations or errors. Here's what it looks like on 4S:

enter image description here

I am doing the configuration in tableView:willDisplayCell:forRowAtIndexPath:

With this code ( myView- exit to a pale yellow top view):

self.myView.layer.cornerRadius = 5.0f;
self.myView.clipsToBounds = YES;

I get this result:

enter image description here

All 4 corners are rounded. But I need to selectively twist the corners, as a rule, both the upper and both lower corners. Here is the code to round the two bottom corners:

CAShapeLayer *shape = [[CAShapeLayer alloc] init];
shape.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.myView.bounds.size.width, self.myView.bounds.size.height)
                                   byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                         cornerRadii:CGSizeMake(5.0f, 5.0f)].CGPath;
self.myView.layer.mask = shape;
self.myView.layer.masksToBounds = YES;

And here is the result:

enter image description here

. .

( ), , , - .

, ?

, ?

+1
4

, - , .

tableView: willDisplayCell: forRowAtIndexPath: : , .

UITableViewCell layoutSubviews.

+1

:

CAShapeLayer *shape = [CAShapeLayer layer];
// Create the path (with only the top-left corner rounded)
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.myView.bounds.bounds 
                                               byRoundingCorners:byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight
                                                     cornerRadii:CGSizeMake(5.0f, 5.0f)];

shape.frame = self.myView.bounds;
shape.path = maskPath.CGPath;

// Set the newly created shape layer as the mask for the image view layer
self.myView.layer.mask = shape;

CALayer renderInContext. , : ?.

+1

[self.myView layoutIfNeeded];

:

[self.myView layoutIfNeeded];

CAShapeLayer *shape = [[CAShapeLayer alloc] init];
shape.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.myView.bounds.size.width, self.myView.bounds.size.height)
                                   byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                         cornerRadii:CGSizeMake(5.0f, 5.0f)].CGPath;
self.myView.layer.mask = shape;
self.myView.layer.masksToBounds = YES;
+1

shape.path = [UIBezierPath bezierPathWithRoundedRect:self.myView.bounds
                                   byRoundingCorners:UIRectCornerBottomRight
                                         cornerRadii:CGSizeMake(5.0f, 5.0f)].CGPath;

shape.frame = self.myView.bounds; //Right before setting your self.mView.layer.mask = shape;
0
source

All Articles