最简单的就是让美工妹妹切个圆的图片喽O(∩_∩)O哈哈~.... 然后[UIimage imageName@:""];
如果圆角图片用的地方不是很多的话 可以用
imageView.layer.masksToBounds = YES;
imageView.layer.cornerRadius = 50;]
去实现....不过如果是tableView上面多处用到了图片圆角 使用layer会造成离屏渲染,会加大GPU的开销,在性能上会大大折扣...
可以使用QuarztCore框架来操作
-(UIImage*) circleImage:(UIImage*) image withParam:(CGFloat) inset {
UIGraphicsBeginImageContext(image.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGRect rect = CGRectMake(inset, inset, image.size.width - inset * 2.0f, image.size.height - inset * 2.0f);
CGContextAddEllipseInRect(context, rect);
CGContextClip(context);
[image drawInRect:rect];
CGContextAddEllipseInRect(context, rect);
CGContextStrokePath(context);
UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newimg;
}
来实现.............恩
还有就是用贝塞尔去画...
self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
UIImage *image =[UIImage imageNamed:@"headerImage"];
UIGraphicsBeginImageContextWithOptions(self.imgView.bounds.size, NO, 1.0);
[[UIBezierPath bezierPathWithRoundedRect:self.imgView.bounds cornerRadius:self.imgView.bounds.size.width/2.0]addClip];
[image drawInRect:self.imgView.bounds];
self.imgView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
(⊙o⊙)…....目前知道的就这三种.......相对来说贝塞尔的不错