2015-08-25 33 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