Last active
December 3, 2020 11:40
-
-
Save brennanMKE/10010625 to your computer and use it in GitHub Desktop.
Revisions
-
brennanMKE revised this gist
Apr 6, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ - (UIImage *)screenshotOfView:(UIView *)view excludingViews:(NSArray *)excludedV NSCAssert(FALSE, @"iOS 7 or later is required."); } // hide all excluded views before capturing screen and keep initial value NSMutableArray *hiddenValues = [@[] mutableCopy]; for (NSUInteger index=0;index<excludedViews.count;index++) { [hiddenValues addObject:[NSNumber numberWithBool:((UIView *)excludedViews[index]).hidden]]; -
brennanMKE created this gist
Apr 6, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ - (UIImage *)screenshotOfView:(UIView *)view excludingViews:(NSArray *)excludedViews { if (!floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) { NSCAssert(FALSE, @"iOS 7 or later is required."); } // hide all exclude views before capturing screen and keep initial value NSMutableArray *hiddenValues = [@[] mutableCopy]; for (NSUInteger index=0;index<excludedViews.count;index++) { [hiddenValues addObject:[NSNumber numberWithBool:((UIView *)excludedViews[index]).hidden]]; ((UIView *)excludedViews[index]).hidden = TRUE; } UIImage *image = nil; UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0); [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); // reset hidden values for (NSUInteger index=0;index<excludedViews.count;index++) { ((UIView *)excludedViews[index]).hidden = [[hiddenValues objectAtIndex:index] boolValue]; } // clean up hiddenValues = nil; return image; }