Created
May 23, 2012 04:03
-
-
Save jwilling/2773202 to your computer and use it in GitHub Desktop.
Simple category for changing window size to fit content
This file contains 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
- (void)resizeWindowForContentSize:(NSSize)size animated:(BOOL)animated { | |
NSRect windowFrame = [self contentRectForFrameRect:[self frame]]; | |
NSRect newWindowFrame = [self frameRectForContentRect: | |
NSMakeRect( NSMinX( windowFrame ), NSMaxY( windowFrame ) - size.height, size.width, size.height )]; | |
[self setFrame:newWindowFrame display:YES animate:animated]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment