iOS 截屏方法,高清、模糊

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

 + (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);//模糊

你可能感兴趣的:(iOS 截屏方法,高清、模糊)