当前位置:首页 > 通信资讯 > 正文

ios 贝塞尔曲线画圆(贝塞尔曲线画圆角)

ios 系统框架已经给我们提供了相应的切割圆角的方法, 但是如果在一个见面有很多控件切割的话会出现卡顿和个别不切得现在

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 /* 创建一个Button */ UIButton * button = [UIButton buttonWithType:(UIButtonTypeSystem)]; [button setFrame:CGRectMake(100, 100, 100, 100)]; [self addSubview:button]; /* 正厂的圆角需求处理方法 */ button.layer.cornerRadius = 10.0f; //弧度 button.layer.masksToBounds = YES; /* 贝塞尔曲线切割 */ /** * * @param UIRectCorner * 左上 UIRectCornerTopLeft = 1 << 0, 左下 UIRectCornerBottomLeft = 1 << 2, 右下 UIRectCornerBottomRight = 1 << 3, 所有角 UIRectCornerAllCorners = ~0UL * */ UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:button.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:button.bounds.size]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init]; //设置大小 maskLayer.frame = button.bounds; //设置图形样子 maskLayer.path = maskPath.CGPath; button.layer.mask = maskLayer;

注意: 如果这里选择两个角 的话如果是选两个对角线 则会切 所有角

比如:UIRectCornerTopLeft | UIRectCornerBottomRight 他就会切割所有角

当然你也可以直接创建个圆角的button

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:http://blog.csdn.net/qq_30402119/article/details/51499992

如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。