Reputation: 1545
I want to shrink a NSWindow, by changing the height of the frame and having that come off of the top of the window. I tried:
NSRect frame = [mainWindow frame];
frame.origin.y += 71;
frame.size.height -= 71;
[mainWindow setFrame:frame display:YES animate:YES];
But it made the window smaller from the bottom, not the top.
Upvotes: 3
Views: 691
Reputation: 39925
In cocoa on OS X, the origin is in the bottom left corner of the screen. This means that increasing the y position of a window will move it up the screen. Since you want to change the top of your window, you want the bottom corner to stay in place, which means you should not change your origin. Simply changing the height will cause your window to shrink from the top.
NSRect frame = [mainWindow frame];
frame.size.height -= 71;
[mainWindow setFrame:frame display:YES animate:YES];
Upvotes: 2