UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(screenWindow.frame.size);//全屏截图,包括window
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData*data=UIImagePNGRepresentation(viewImage);
NSString*path=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
NSString*file=[path stringByAppendingPathComponent:@"Img.data"];
[NSKeyedArchiver archiveRootObject:data toFile:file];
UIImage*imgae=[UIImage imageWithData:data];
iOS 代码截图
最新推荐文章于 2019-12-11 15:40:44 发布