From 737d71ea6b44993d2e37be3eedf95b648d29ea41 Mon Sep 17 00:00:00 2001 From: chixm Date: Sun, 8 Mar 2020 00:44:19 +0800 Subject: [PATCH] fix #206 #208 --- XHLaunchAd/XHLaunchAd/XHLaunchImageView.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/XHLaunchAd/XHLaunchAd/XHLaunchImageView.m b/XHLaunchAd/XHLaunchAd/XHLaunchImageView.m index b35ca48..5f31f9f 100644 --- a/XHLaunchAd/XHLaunchAd/XHLaunchImageView.m +++ b/XHLaunchAd/XHLaunchAd/XHLaunchImageView.m @@ -77,11 +77,12 @@ -(UIImage*)imageFromView:(UIView*)view{ CGSize size = view.bounds.size; //参数1:表示区域大小 参数2:如果需要显示半透明效果,需要传NO,否则传YES 参数3:屏幕密度 UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale); - if ([view respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) { - [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; - }else{ - [view.layer renderInContext:UIGraphicsGetCurrentContext()]; - } + /** + 基于以下Issues反馈暂不使用drawViewHierarchyInRect:afterScreenUpdates:方法截图 + 1、如果直接在AppDelgate里直接初始化XHLaunchAd,该方法截图失败返回NO(https://github.com/CoderZhuXH/XHLaunchAd/issues/206); + 2、有人反馈在iOS 11.4真机crash(https://github.com/CoderZhuXH/XHLaunchAd/issues/208)。 + */ + [view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image;