Skip to content

Instantly share code, notes, and snippets.

@jwilling
Created May 23, 2012 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwilling/2773202 to your computer and use it in GitHub Desktop.
Save jwilling/2773202 to your computer and use it in GitHub Desktop.
Simple category for changing window size to fit content
- (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