【问题标题】:Round top corners in UITableViewUITableView 中的圆顶角
【发布时间】:2013-07-03 15:31:01
【问题描述】:

我确实在 UItableView 中添加了圆角,但只在顶角。 问题是当我在 UItableView 中使用掩码时,UItableView 只显示前 4 个单元格。

当我从掩码中注释代码时,tableview 工作正常..

这是我的代码:

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];

【问题讨论】:

  • 看起来几乎与同一张海报中的this question 完全相同。

标签: objective-c ios4 uitableview iphone-sdk-3.0


【解决方案1】:

一种方法是在表格视图中添加标题:

- (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;
}

【讨论】:

    猜你喜欢
    • 2012-01-27
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    • 1970-01-01
    • 2011-11-09
    • 2016-09-06
    • 2018-02-21
    相关资源
    最近更新 更多