美文网首页
截取View为图片

截取View为图片

作者: 四季的风 | 来源:发表于2019-12-03 15:10 被阅读0次

+ (UIImage*)snapshot:(UIView *)shotView {   
     UIGraphicsBeginImageContext(shotView.frame.size);   
     UIGraphicsBeginImageContextWithOptions(shotView.frame.size, NO, [[UIScreen mainScreen] scale]);   
     CGContextRef context = UIGraphicsGetCurrentContext(); 
      [shotView.layer renderInContext:context];   
     UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();   
     UIGraphicsEndImageContext(); 
     return screenShot;
 }

相关文章

网友评论

      本文标题:截取View为图片

      本文链接:https://www.haomeiwen.com/subject/diwbmftx.html