我的每个UITableView单元上都有一个UIImageView,它显示一个远程图像(使用SDWebImage)。我已经对图像视图进行了一些QuartzCore层样式设置,如下所示:
UIImageView *itemImageView = (UIImageView *)[cell viewWithTag:100];
itemImageView.layer.borderWidth = 1.0f;
itemImageView.layer.borderColor = [UIColor concreteColor].CGColor;
itemImageView.layer.masksToBounds = NO;
itemImageView.clipsToBounds = YES;所以现在我有一个50x50的正方形,有一个灰色的边框,但我想让它变成圆形而不是正方形。应用程序Hemoglobe在表视图中使用圆形图像,这就是我想要实现的效果。然而,我不想使用cornerRadius,因为那会降低我的滚动FPS。
下面是显示循环UIImageViews的Hemoglobe:

有什么方法可以达到这种效果吗?谢谢。
发布于 2013-08-28 03:41:49
只需将cornerRadius设置为宽度或高度的一半(假设对象的视图为正方形)。
例如,如果对象的视图的宽度和高度都为50:
itemImageView.layer.cornerRadius = 25;更新-正如用户atulkhatri指出的那样,如果你不添加:
itemImageView.layer.masksToBounds = YES;发布于 2014-05-22 19:11:31
添加边框的步骤
self.ImageView.layer.borderWidth = 3.0f;
self.ImageView.layer.borderColor = [UIColor whiteColor].CGColor;对于圆形
self.ImageView.layer.cornerRadius = self.ImageView.frame.size.width / 2;
self.ImageView.clipsToBounds = YES;请参考此链接
http://www.appcoda.com/ios-programming-circular-image-calayer/
发布于 2013-07-18 19:51:32
使用此代码..这将是有帮助的..
UIImage* image = ...;
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:50.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();它对我来说很好。:)
https://stackoverflow.com/questions/17721934
复制相似问题