码迷,mamicode.com
首页 > 其他好文 > 详细

给头像设置圆角的卡顿解决

时间:2015-12-03 00:05:39      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

加入在tableView的每个cell里都有一个圆角头像,因为在layer.corner...开销过大,所以会造成卡顿,可以通过贝塞尔曲线进行绘制。

// 如下所示

// Get your image somehow
UIImage *image = [UIImage imageNamed:@"image.jpg"];

// Begin a new image that will be the new image with the rounded corners 
// (here with the size of an UIImageView)
 UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 1.0);

 // Add a clip before drawing anything, in the shape of an rounded rect
  [[UIBezierPath bezierPathWithRoundedRect:imageView.bounds 
                        cornerRadius:10.0] addClip];
 // Draw your image
[image drawInRect:imageView.bounds];

 // Get the image, here setting the UIImageView image
  imageView.image = UIGraphicsGetImageFromCurrentImageContext();

 // Lets forget about that we were drawing
  UIGraphicsEndImageContext();

 

给头像设置圆角的卡顿解决

标签:

原文地址:http://www.cnblogs.com/zhaoyunboy/p/how-to-clip-imageView-cornerradius.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!