【发布时间】:2014-10-26 07:19:16
【问题描述】:
有没有办法只为 UIView 的左下角、右下角和左上角设置cornerRadius?
我尝试了以下操作,但最终导致视图消失。下面的代码有什么问题吗?
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(20.0, 20.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
【问题讨论】:
-
尝试使用
UIBezierPath* maskPath = [UIBezierPath new];,然后使用addLineToPoint:、addArcWithCenter:radius:startAngle:endAngle:clockwise:方法。 -
您的代码似乎没问题。只需检查您是否已添加 QuartzCore 框架并在您编写此代码的类中导入。我不知道具体情况,但我之前发生过。
标签: ios objective-c iphone xcode ipad