扫码关注官方订阅号
一般button都是带着四个圆角的 如果定义只有上面的那条边,即只有左上和右上是圆角的button , 其他两个是直角
人生最曼妙的风景,竟是内心的淡定与从容!
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?
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
参考:Rounded UIView using CALayers - only some corners - How?