如何在imageview ios7中获取圆形图像
Posted
技术标签:
【中文标题】如何在imageview ios7中获取圆形图像【英文标题】:How to get circular image in an imageview ios7 【发布时间】:2014-03-17 11:10:10 【问题描述】:如何从 UIImage 中获取圆形图像并将其显示在图像视图上。图像应与 ios7 调用历史记录中显示的图像相似
【问题讨论】:
【参考方案1】:- (UIImage *)getRoundedRectImageFromImage :(UIImage *)image onReferenceView :
(UIImageView*)imageView withCornerRadius :(float)cornerRadius
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 1.0);
[[UIBezierPath bezierPathWithRoundedRect:imageView.bounds
cornerRadius:cornerRadius] addClip];
[image drawInRect:imageView.bounds];
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return finalImage;
And call the method like this
imageView.image = [self getRoundedRectImageFromImage:image
onReferenceView:
imageView withCornerRadius:imageView.frame.size.width/2];
imageView.clipsToBounds=YES;
imageView.layer.masksToBounds = YES;
【讨论】:
以上是关于如何在imageview ios7中获取圆形图像的主要内容,如果未能解决你的问题,请参考以下文章
如何在圆形 imageView android 上添加一个阴影和边界