iOS切圆角的方式有三种
1. 通过设置layer的属性
最简单的一种,但是很影响性能,一般在正常的开发中使用很少.
self.button.layer.cornerRadius =30;
self.button.layer.masksToBounds= YES;
2.使用贝塞尔曲线UIBezierPath和Core Graphics 使用不多
貌似只能使用ImageView 这个不太懂
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100,100,100,100)];
imageView.center=self.view.center;
imageView.image= [UIImage imageNamed:@"1"];//开始对imageView进行画图UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, [UIScreen mainScreen].scale);//使用贝塞尔曲线画出一个圆形图[[UIBezierPath bezierPathWithRoundedRect:imageView.bounds cornerRadius:imageView.frame.size.width] addClip];
[imageView drawRect:imageView.bounds];
imageView.image=UIGraphicsGetImageFromCurrentImageContext();
UIImage*image =UIGraphicsGetImageFromCurrentImageContext();
[self.button setImage:image forState:UIControlS