I was wondering how I could constrain an application window to be resized o开发者_JAVA技巧nly proportionally? I want it to keep the ratio so as not to distort photos/videos.
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];
}
You don't resize applications, you resize windows. You can use -[NSWindow setContentAspectRatio:]
.
精彩评论