将某视图View转换为UIImage
+ (UIImage *)getSharedScreenView{ UIWindow *screenWindow = [[UIApplication sharedApplication]keyWindow]; ScreenView *currentView = [[[self class] alloc] init]; currentView.frame = screenWindow.bounds; [screenWindow addSubview:currentView]; //UIGraphicsBeginImageContext() 图片会失真模糊 UIGraphicsBeginImageContextWithOptions(screenWindow.frame.size, NO, 0.0);//图片不模糊 [screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage* viewImage =UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [currentView removeFromSuperview]; //UIImageWriteToSavedPhotosAlbum(viewImage,nil,nil,nil); //写入到相册 return viewImage; }
posted on 2018-01-12 10:35 JieFangZhe 阅读(101) 评论(0) 收藏 举报
浙公网安备 33010602011771号