扫码关注官方订阅号
怎样给UIScrollView设置圆角 而且设置上边两个角是圆角
人生最曼妙的风景,竟是内心的淡定与从容!
不仅仅适用于UIScrollView,可以使用在任何UIView上。
UIScrollView
UIView
Category
@implementation UIView (UIViewRoundCorners) - (void)applyRoundCorners:(UIRectCorner)corners radius:(CGFloat)radius { UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radius, radius)]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = self.bounds; maskLayer.path = maskPath.CGPath; self.layer.mask = maskLayer; } @end
[view applyRoundCorners:UIRectCornerTopRight|UIRectCornerTopLeft radius:10];
Rounded UIView using CALayers - only some corners - How?
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
不仅仅适用于
UIScrollView,可以使用在任何UIView上。1. 给
UIView添加一个Category2. 设置上面左右两个角变圆
参考
Rounded UIView using CALayers - only some corners - How?