Example project: http://cl.ly/1l1x1A0J3o2X
I have a child view controller that has a UITableView in it, and this view controller sits on top of another view controller. I want to give the bottom of it rounded corners (but only the bottom).
In my UITableView subclass I have this code to round the bottom corners.
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(5.0, 5.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
self.backgroundColor = [UIColor colorWithRed:0.169 green:0.169 blue:0.169 alpha:1];
}
return self;
}
Which does indeed round them, but as soon as I scroll the table view it moves it up further and decreases in height (seemingly at least).
However, if I simply use self.layer.cornerRadius = 5.0
it completely operates fine.
Does anyone know why this behaviour might be the case?