现在的位置: 首页 > 综合 > 正文

IView 转 UIImage

2018年07月13日 ⁄ 综合 ⁄ 共 524字 ⁄ 字号 评论关闭

- (UIImage*) imageWithUIView:(UIView*) view{

    // 创建一个bitmap的context  

    // 并把它设置成为当前正在使用的context  

    UIGraphicsBeginImageContext(view.bounds.size);  

    CGContextRef currnetContext = UIGraphicsGetCurrentContext();

    //[view.layer drawInContext:currnetContext];

    [view.layer renderInContext:currnetContext];

    // 从当前context中创建一个改变大小后的图片  

    UIImage* image = UIGraphicsGetImageFromCurrentImageContext();  

    // 使当前的context出堆栈  

    UIGraphicsEndImageContext();  

    return image;

}

转自:http://blog.csdn.net/iukey/article/details/7662612

抱歉!评论已关闭.