OGeek|极客世界-中国程序员成长平台

标题: ios - 圆角仅适用于 UITableView 的底部边缘 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:05
标题: ios - 圆角仅适用于 UITableView 的底部边缘

我正在使用下面的代码为 tableView 的底部边缘制作圆角

CALayer *capa = self.patientTableView.layer;

//Round
CGRect bounds = capa.bounds;

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bounds
                                               byRoundingCornersUIRectCornerBottomLeft | 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)。



Best Answer-推荐答案


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

view hierarchy

关于ios - 圆角仅适用于 UITableView 的底部边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32205579/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4