如何从UIImage获取圆形图像并将其显示在图像视图上。图像应该与IOS7中显示的图像一样调用历史记录
答案 0 :(得分:2)
- (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;