diff --git a/YBImageBrowser/Helper/YBIBUtilities.m b/YBImageBrowser/Helper/YBIBUtilities.m index ba074f8..4e9b1ac 100644 --- a/YBImageBrowser/Helper/YBIBUtilities.m +++ b/YBImageBrowser/Helper/YBIBUtilities.m @@ -91,11 +91,27 @@ CGFloat YBIBSafeAreaBottomHeight(void) { } UIImage *YBIBSnapshotView(UIView *view) { - UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [UIScreen mainScreen].scale); - [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return image; + // UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [UIScreen mainScreen].scale); + // [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; + // UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + // UIGraphicsEndImageContext(); + // return image; + if (@available(iOS 10.0, *)) { + UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init]; + format.scale = [UIScreen mainScreen].scale; + format.opaque = YES; + UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:view.bounds.size format:format]; + UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull context) { + [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; + }]; + return image; + } else { + UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [UIScreen mainScreen].scale); + [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return image; + } } UIEdgeInsets YBIBPaddingByBrowserOrientation(UIDeviceOrientation orientation) {