【发布时间】:2014-01-22 13:37:19
【问题描述】:
我正在创建 uiview 按钮
'Button = [UIButton buttonWithType:UIButtonTypeCustom];
在选定状态和正常状态下具有颜色。 关键是我想改变面具。使我的按钮具有一侧半径角。
为此,我正在使用方法:
- (void)cornerMaskRadiusAtButton:(UIButton*)button leftSide:(BOOL)side
{
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = button.bounds;
UIBezierPath *roundedPath;
if(side){
roundedPath =[UIBezierPath bezierPathWithRoundedRect:maskLayer.bounds
byRoundingCorners:UIRectCornerTopLeft |
UIRectCornerBottomLeft
cornerRadii:CGSizeMake(18.f, 18.f)];
}
else{
roundedPath = [UIBezierPath bezierPathWithRoundedRect:maskLayer.bounds
byRoundingCorners:UIRectCornerTopRight |
UIRectCornerBottomRight
cornerRadii:CGSizeMake(18.f, 18.f)];
}
maskLayer.path = [roundedPath CGPath];
button.layer.mask = maskLayer;
}
但是结果是这样的:
在我称之为方法之后:
[self cornerMaskRadiusAtButton:Button leftSide:NO];
Button.layer.borderColor = [UIColor whiteColor].CGColor;
Button.layer.borderWidth = 1.;
但是边框是错误的。
如何修复边界线?
【问题讨论】:
标签: ios ipad uiview layer mask