iOS 截屏
来源:互联网 发布:水利水电预算软件 编辑:程序博客网 时间:2024/05/22 00:11
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];UIGraphicsBeginImageContextWithOptions(screenWindow.frame.size, NO, 0.0); // no ritinaCGContextRef context = UIGraphicsGetCurrentContext();CGContextSaveGState(context);for (UIWindow *window in [[UIApplication sharedApplication] windows]) { if(window == screenWindow) { break; }else{ [window.layer renderInContext:context]; }}// // ////////////////////////if ([screenWindow respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) { [screenWindow drawViewHierarchyInRect:screenWindow.bounds afterScreenUpdates:YES];} else { [screenWindow.layer renderInContext:context];}CGContextRestoreGState(context);UIImage *image = UIGraphicsGetImageFromCurrentImageContext();screenWindow.layer.contents = nil;UIGraphicsEndImageContext();float iOSVersion = [UIDevice currentDevice].systemVersion.floatValue;if(iOSVersion < 8.0){ image = [self rotateUIInterfaceOrientationImage:image];}
-(UIImage *)rotateUIInterfaceOrientationImage:(UIImage *)image{UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];switch (orientation) { case UIInterfaceOrientationLandscapeRight: { LOG(@"右"); image = [UIImage imageWithCGImage:image.CGImage scale:1 orientation:UIImageOrientationLeft]; } break; case UIInterfaceOrientationLandscapeLeft: { LOG(@"左"); image = [UIImage imageWithCGImage:image.CGImage scale:1 orientation:UIImageOrientationRight]; } break; case UIInterfaceOrientationPortraitUpsideDown: { LOG(@"上"); image = [UIImage imageWithCGImage:image.CGImage scale:1 orientation:UIImageOrientationDown]; } break; case UIInterfaceOrientationPortrait: { LOG(@"下"); image = [UIImage imageWithCGImage:image.CGImage scale:1 orientation:UIImageOrientationUp]; } break; case UIInterfaceOrientationUnknown: { LOG(@"不知道"); } break; default: break;}return image;}
0 0
- IOS 截屏
- IOS 截屏
- IOS 截屏
- ios截屏
- iOS截屏
- iOS 截屏
- iOS截屏
- iOS 截屏
- iOS 截屏
- IOS截屏
- iOS截屏
- ios 截屏
- iOS截屏
- iOS 截屏
- iOS 截屏
- iOS截屏
- iOS-截屏
- iOS 截屏
- get不上去的,可能就需要用post 传 js ajax
- MVP中RxJava的使用
- 树 2016.7.13
- SAP中的默认帐户与密码
- Java中如何获取Spring中配置的bean
- iOS 截屏
- Android NFC P2P开发基础
- 文件对比工具Beyond Compare使用方法
- 一步一步学ROP之linux_x86篇
- import 与import ... from 区别
- C/C++程序员必须熟练应用的开源项目
- Android5.0 SnackBar使用小结
- 【Unity技巧】Unity中的优化技术
- 假装高逼格的公司都死掉了