ios 把view生成image, 保持清晰度

时间:2014-09-23 13:36:05   收藏:0   阅读:515

#pragma mark 生成image

- (UIImage *)makeImageWithView:(UIView *)view

{

    CGSize s = view.bounds.size;

    // 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传NO,否则传YES。第三个参数就是屏幕密度了,关键就是第三个参数。

    UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);

    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage*image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return image;

}

原文:http://blog.csdn.net/alincexiaohao/article/details/39496821

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!