【问题标题】:How to round only corners on a UITableView?如何在 UITableView 上只圆角?
【发布时间】:2012-06-15 17:21:11
【问题描述】:

我正在尝试仅舍入我的表格视图的右上角和左上角。我正在使用下面的代码,它似乎只是在左上角四舍五入......

CAShapeLayer *topLayer = [CAShapeLayer layer];
UIBezierPath *roundedPath = 
[UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(9.f, 9.0f)];    
topLayer.path = [roundedPath CGPath];

【问题讨论】:

标签: ios rounded-corners uibezierpath uitableview


【解决方案1】:

希望这会奏效。 找到顶角路径以创建遮罩层

UIBezierPath *PathToMask;
PathToMask = [UIBezierPath bezierPathWithRoundedRect:self.testView.bounds
                                 byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
                                       cornerRadii:CGSizeMake(8.0, 8.0)];

使用 UIBezierPath maskPath 创建形状图层蒙版

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 
maskLayer.frame =self.testView.bounds;
maskLayer.path = PathToMask.CGPath;

设置遮罩层maskLayer

self.testView.layer.mask = maskLayer;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-07
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    相关资源
    最近更新 更多