Maxwell Dergosits
Maxwell Dergosits

Reputation: 307

Maintain aspect ratio of a view on a NSWindow, rather than the aspect.

I have an image view that i would like to maintain the aspect ratio of but still be able to resize the window.

Upvotes: 3

Views: 1113

Answers (2)

dbainbridge
dbainbridge

Reputation: 1202

Set the image view scaling property to "proportionally up or down" in interface builder and set the content aspect ratio of the window containing it:

        [window setContentAspectRatio:myImageView.image.size];

Upvotes: 3

rdelmar
rdelmar

Reputation: 104082

As far as I know, there's no way to do this "automatically", you'll need to follow the frame change of the window (with the delegate method windowWillResize:toSize:) and adjust your image view's frame however you want it to change.

Upvotes: 0

Related Questions