//
获取当前屏幕视图的快照图片
- ( UIImage *)capture {
UIView *view = self . mainViewController . view ;
if (view == nil ) {
NSLog ( @" 快照视图为空 " );
return nil ;
}
UIGraphicsBeginImageContextWithOptions (view. bounds . size , view. opaque , 0.0);
[view. layer renderInContext : UIGraphicsGetCurrentContext ()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext ();
NSLog ( @"%f,%f" ,img. size . height ,img. size . width );
UIGraphicsEndImageContext ();
return img;
}
- ( UIImage *)capture {
UIView *view = self . mainViewController . view ;
if (view == nil ) {
NSLog ( @" 快照视图为空 " );
return nil ;
}
UIGraphicsBeginImageContextWithOptions (view. bounds . size , view. opaque , 0.0);
[view. layer renderInContext : UIGraphicsGetCurrentContext ()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext ();
NSLog ( @"%f,%f" ,img. size . height ,img. size . width );
UIGraphicsEndImageContext ();
return img;
}