将一个view转换为图片
2018-02-12 本文已影响0人
bingo哥
//开启位图上下文,将图片渲染到位图上下文
UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[self.layer renderInContext:ctx];
UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();