iOS 屏幕截图
/**
* 截取当前屏幕视图
*/
+(UIImage *)screenShotWithShotScreenView
{
UIImage *iimahe = [self screenShotWithShotView:[UIApplication sharedApplication].keyWindow];
return iimahe;
}
/**
* 截图
*
* @param shotView 需截图的view
*/
-(UIImage *)screenShotWithShotView:(UIView *)shotView
{
UIGraphicsBeginImageContextWithOptions(shotView.bounds.size, NO, [UIScreen mainScreen].scale);//[UIScreen mainScreen].scale 屏幕分辨率,如果缺少这个,截出来的图就会模糊
CGContextRef context = UIGraphicsGetCurrentContext();
[shotView.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}

浙公网安备 33010602011771号