I have a UITableViewCell
with multiple subviews. One of the subviews is a UILabel
and the cell\'s height is dynamically sized based on the amount of te
I finally got it. I'm not sure if this is the correct place to put this or if it might cause performance problems, but so far it works perfectly:
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.mySubview.bounds
byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight)
cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = self.mySubview.bounds;
maskLayer.path = maskPath.CGPath;
self.mySubview.layer.mask = maskLayer;
}
I had to override drawRect:
in my UITableViewCell
subclass and set the mask layer there.
I have had same problem and doing things in - (void)drawRect:(CGRect)rect
does the work but it could be costly in terms of performance.
You can call your clipping or shadow methods in perform selector
[self performSelector:@selector(<your drawing method>) withObject:nil afterDelay:0.0000001 ];//a very low delay