Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize Cocoa windows proportionally

I was wondering how I could constrain an application window to be resized only proportionally? I want it to keep the ratio so as not to distort photos/videos.

like image 599
Anas Avatar asked Mar 13 '11 17:03

Anas


2 Answers

You would probably do this in your application delegate; in a standard project template, that object has a reference to your app's main window.

- (void)awakeFromNib {
    // Keep the aspect ratio constant at its current value
    [window setAspectRatio:window.frame.size];
}
like image 189
jscs Avatar answered Oct 10 '22 12:10

jscs


You don't resize applications, you resize windows. You can use -[NSWindow setContentAspectRatio:].

like image 28
Nicholas Riley Avatar answered Oct 10 '22 12:10

Nicholas Riley