Created
September 4, 2011 06:11
-
-
Save venj/1192366 to your computer and use it in GitHub Desktop.
Resize Window
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
/* NSWindow+Extension.h */ | |
#import <Foundation/Foundation.h> | |
@interface NSWindow(Extension) | |
- (void)resizeTo:(NSSize)newSize display:(BOOL)display animated:(BOOL)animated; | |
- (void)resizeTo:(NSSize)newSize; | |
@end | |
/* NSWindow+Extension.m */ | |
#import "NSWindow+Extension.h" | |
@implementation NSWindow(Extension) | |
- (void)resizeTo:(NSSize)newSize display:(BOOL)display animated:(BOOL)animated { | |
CGRect oldFrame = self.frame; | |
CGRect newFrame = CGRectMake(oldFrame.origin.x, oldFrame.origin.y - (newSize.height - oldFrame.size.height), newSize.width, newSize.height); | |
[self setFrame:newFrame display:display animate:animated]; | |
} | |
- (void)resizeTo:(NSSize)newSize { | |
[self resizeTo:newSize display:YES animated:YES]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment