您的位置:首页 > 产品设计 > UI/UE

设置UIView几个角为圆角

2015-07-21 11:57 429 查看
UIButton *btn = [[UIButton
alloc] initWithFrame:CGRectMake(PhaseHalf(CGRectGetWidth(self.view.bounds),kWidth),
PhaseHalf(CGRectGetHeight(self.view.bounds),kWidth),
kWidth,
kWidth)];

[btn setBackgroundColor:[UIColor
redColor]];
[self.view
addSubview:btn];

[btn addTarget:self
action:@selector(onBtnTouchUpInside:)
forControlEvents:UIControlEventTouchUpInside];

UIBezierPath *maskPath = [UIBezierPath
bezierPathWithRoundedRect:btn.bounds
byRoundingCorners:UIRectCornerBottomLeft|
UIRectCornerBottomRight cornerRadii:CGSizeMake(10.0,
10.0)];

CAShapeLayer *maskLayer = [CAShapeLayer
layer];
maskLayer.frame = btn.bounds;
maskLayer.path = maskPath.CGPath;
btn.layer.mask = maskLayer;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: