Last active
August 29, 2015 13:57
-
Star
(103)
You must be signed in to star a gist -
Fork
(3)
You must be signed in to fork a gist
-
-
Save matthiasplappert/9493050 to your computer and use it in GitHub Desktop.
QuickLook Debugging for `UIView`
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 characters
@interface UIView (MPAdditions) | |
@end | |
@implementation UIView (MPAdditions) | |
- (id)debugQuickLookObject { | |
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) { | |
return nil; | |
} | |
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.window.screen.scale); | |
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} | |
@end |
This is elegantly simple! Thanks!
or just
- (id)
debugQuickLookObject
{
return self;
}
Apparently this works without any code in Xcode 5.1 and above, although I found it not very reliable.
@matthiasplappert You can create nice cocoapod :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example: