Skip to content

Instantly share code, notes, and snippets.

@matthiasplappert
Last active August 29, 2015 13:57
Show Gist options
  • 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.
Save matthiasplappert/9493050 to your computer and use it in GitHub Desktop.
QuickLook Debugging for `UIView`
@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
@matthiasplappert
Copy link
Author

Here's an example: example

@robinhp
Copy link

robinhp commented Mar 12, 2014

This is elegantly simple! Thanks!

@dev4dev
Copy link

dev4dev commented Mar 12, 2014

or just

- (id)
debugQuickLookObject
{
    return self;
}

@matthiasplappert
Copy link
Author

Apparently this works without any code in Xcode 5.1 and above, although I found it not very reliable.

@kam800
Copy link

kam800 commented Mar 12, 2014

@matthiasplappert You can create nice cocoapod :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment