Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Mar 11, 2014

Here's an example: example

@robinhp

This comment has been minimized.

Copy link

commented Mar 12, 2014

This is elegantly simple! Thanks!

@dev4dev

This comment has been minimized.

Copy link

commented Mar 12, 2014

or just

- (id)
debugQuickLookObject
{
    return self;
}
@matthiasplappert

This comment has been minimized.

Copy link
Owner Author

commented Mar 12, 2014

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

@kam800

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.