2015-08-25 29 views
2

我使用下面的代码,使圆角只为的tableView圆角只为UITableView的

CALayer *capa = self.patientTableView.layer; 

//Round 
CGRect bounds = capa.bounds; 

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bounds 
               byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) 
                cornerRadii:CGSizeMake(10.0, 10.0)]; 

CAShapeLayer *maskLayer = [CAShapeLayer layer]; 
maskLayer.frame = bounds; 
maskLayer.path = maskPath.CGPath; 

[capa addSublayer:maskLayer]; 
capa.mask = maskLayer; 

此代码工作正常的底部边缘,但tableview中没有显示出的底部边缘内容低于其框架高度(但它滚动到其offset.y)。

+1

顺便说一句,你不必添加遮罩层作为子图层。只需设置现有图层的“mask”属性即可。 – Rob

回答

1

您可以通过将表视图放在UIView中来解决此问题,然后将该掩码应用于该容器视图。这样,面罩将不会随表格视图的contentOffset一起移动。

view hierarchy