网站做防御,网页模板,哪里有做软件开发的公司,奥尔马手表官方网站ios 系统框架已经给我们提供了相应的切割圆角的方法, 但是如果在一个见面有很多控件切割的话会出现卡顿和个别不切的现象 ?123456789101112131415161718192021222324252627/* 创建一个Button */UIButton * button [UIButton buttonWithType:(UIButtonTypeSystem)];[button se…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://www.jb51.net/article/118140.htm 感谢分享 但是在实际开发中 不建议这么写 18年04月为止切圆角的性能最好的方法是用 贝塞尔曲线 和 context上下文来 画圆角。 用 button.layer.masksToBounds 和 button.layer.mask都会对性能带来很大的消耗