标签:
加入在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