UITableView中的顶部圆角
问题描述:
我在UItableView中添加了圆角,但只在顶角。 问题是,当我在UItableView中使用掩码时,UItableView只显示前4个单元格。UITableView中的顶部圆角
当我从评论面具的代码中,实现代码如下工作正常..
这里是我的代码:
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:_tbFeeds.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(9.0, 9.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _tbFeeds.bounds;
maskLayer.path = maskPath.CGPath;
_tbFeeds.layer.mask = maskLayer; //tbfeeds is my tableview
[maskLayer release];
答
办法做到这将是一个头添加到实现代码如下:
- (void)loadView {
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 10)]; // height of header (10)
[headerView setBackgroundColor:[UIColor whiteColor]]; // color of header (white)
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:headerView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(5.0, 5.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = headerView.bounds;
maskLayer.path = maskPath.CGPath;
headerView.layer.mask = maskLayer;
self.tableView.tableHeaderView = headerView;
}
答
请参考以下链接查询:
https://gist.github.com/robin/62684
看起来像来自同一张海报的[这个问题]的几乎完全重复(http://*.com/questions/17451438/uitableview-doesnt-work-fine-when-i-use-mask)。 –