I need to display NSImageView
on resizable NSWindow
. The image displayed in the view should scale down if it's too big to fit image view in the widnow and it should also change its size when resizing the window. I am able to achieve correct behavior using Auto-Layout, and setting imageScaling
property of NSImageView
to NSImageScaleProportionallyDown
. Unfortunately it's not working when my image view's imageFrameStyle
property is set to NSImageFrameNone
(it works for any other option like NSImageFramePhoto
or NSImageFrameGrayBezel
). I don't want any frame to be displayed, like with NSImageFrameNone
, but disabling the frame breaks autoresizing - it looks like with frame set to NSImageFrameNone
image is not scaled down and NSImageView
is scaled up to match displayed image size. Anyone have solution for that issue?
It occurs that it's easier than I thought. The problem was with Auto-Layout, not with NSImageView scaling logic. Using InterfaceBuilder with my image view selected I had to change "Content Compression Resistance Priority" to lower value (it's located on Size Inspector tab in Xcode5). That solved my problem and the image is now scaled properly when resizing window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With