iOS 截屏方法,高清、模糊

2017-11-24  本文已影响329人  半夏吖

项目中需要用当前页面的截屏保存为图片

 + (UIImage *)currentViewScreenPhoto:(UIView *)topView
{ 
    // 高清截屏
    UIGraphicsBeginImageContextWithOptions(topView.bounds.size, NO, 0.0); 
    [topView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    // 保存为图片
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return viewImage; 
}

高清

UIGraphicsBeginImageContextWithOptions(topView.bounds.size, NO, 0.0);//原图

模糊

UIGraphicsBeginImageContext(topView.bounds.size);//模糊

上一篇 下一篇

猜你喜欢

热点阅读