【发布时间】:2014-03-17 11:10:10
【问题描述】:
如何从 UIImage 中获取圆形图像并将其显示在图像视图上。图像应与 IOS7 调用历史记录中显示的图像相似
【问题讨论】:
标签: ios ios7 uiimageview uiimage
如何从 UIImage 中获取圆形图像并将其显示在图像视图上。图像应与 IOS7 调用历史记录中显示的图像相似
【问题讨论】:
标签: ios ios7 uiimageview uiimage
- (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;
【讨论】: