【问题标题】:UIView corner issue [duplicate]UIView角落问题[重复]
【发布时间】:2016-10-16 23:42:11
【问题描述】:

我有蓝色 UIView,我想要顶角。
这是我的代码:

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.backgroundContentView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(20.0, 20.0)];
CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
shapeLayer.frame = self.backgroundContentView.bounds;
shapeLayer.path  = path.CGPath;
self.backgroundContentView.layer.mask = shapeLayer;

但我只有左上角。为什么?

【问题讨论】:

标签: ios objective-c uiview


【解决方案1】:

使用此代码将内存分配给CALayer

CAShapeLayer *maskLayer = [CAShapeLayer layer];

【讨论】:

    猜你喜欢
    • 2011-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多