【问题标题】:How to get circular image in an imageview ios7如何在imageview ios7中获取圆形图像
【发布时间】:2014-03-17 11:10:10
【问题描述】:

如何从 UIImage 中获取圆形图像并将其显示在图像视图上。图像应与 IOS7 调用历史记录中显示的图像相似

【问题讨论】:

    标签: ios ios7 uiimageview uiimage


    【解决方案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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-01
      • 2017-02-14
      • 1970-01-01
      • 2014-05-21
      • 1970-01-01
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多