如果定义一个只有上边圆角的UIButton
一般button都是带着四个圆角的
如果定义只有上面的那条边,即只有左上和右上是圆角的button , 其他两个是直角
zodiac
11 years, 11 months ago
Answers
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];
view2.backgroundColor = [UIColor redColor];
[self.view addSubview:view2];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view2.bounds;
maskLayer.path = maskPath.CGPath;
view2.layer.mask = maskLayer;
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
参考: Rounded UIView using CALayers - only some corners - How?
肛门♂幽灵
answered 11 years, 11 months ago