佚名通过本文主要向大家介绍了月圆人圆事事圆满,月圆人圆,月圆人不圆,八月中秋月圆人不圆,中秋佳节 月圆人圆等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题:月圆人圆事事圆 如果定义一个只有上边圆角的UIButton
描述:
解决方案1:
描述:
一般button都是带着四个圆角的
如果定义只有上面的那条边,即只有左上和右上是圆角的button , 其他两个是直角
解决方案1:
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?