Adjust NSWindow height from below?

Suppose I have a window called mWindow . To increase the height, I would do this with a frame:

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

However, this increases the height of the top of the window, not the bottom. How can I do this to add more windows to the bottom rather than the top?

+4
source share
3 answers

Due to how the coordinates work in Cocoa, you will need to take a few 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 for NSWindow.

+8
source

You can always adjust the starting position accordingly, i.e. make it higher and move it down.

+1
source

I am using this snippet. You must configure origin.y to match offset

 func change(height: CGFloat) { var frame = window.frame let offset = height - frame.size.height frame.size.height += offset frame.origin.y -= offset window.setFrame(rect, display: true) } 
+1
source

All Articles