iOS技术交流收藏

iOS 如何把view转成image

2015-12-30  本文已影响2102人  lucifrom_long

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

{

UIGraphicsBeginImageContext(view.bounds.size);

CGContextRef context = UIGraphicsGetCurrentContext();

[view.layer renderInContext:context];

UIImage* tImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return tImage;

}

注意:此方法不是线程安全的。使用时需注意!

上一篇 下一篇

猜你喜欢

热点阅读