Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjust NSWindow height from bottom?

Suppose I have a window named mWindow. To increase the height I would do this to the frame:

NSRect windowFrame = [mWindow frame]; 
windowFrame.size.height += 100.0f;
[mWindow setFrame:windowFrame];

However, this increase the height of the top of the window, not the bottom. How can I make it add more window at the bottom instead of the top?

like image 551
Catastrophe Avatar asked Dec 22 '22 12:12

Catastrophe


2 Answers

Because of the way coordinates work in Cocoa, you'll have to do some extra steps to make this work:

NSRect windowFrame = [mWindow frame];
windowFrame.size.height += 100;
windowFrame.origin.y -= 100;
[mWindow setFrame:windowFrame display:YES];

Alternatively, you can use the setFrameOrigin: or setFrameTopLeftPoint: methods of NSWindow.

like image 177
jtbandes Avatar answered Dec 24 '22 01:12

jtbandes


You can always adjust the origin accordingly, i.e. make it higher and move it downwards.

like image 22
Eiko Avatar answered Dec 24 '22 01:12

Eiko