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?
Asked
Active
Viewed 2,802 times
10

Darrarski
- 3,882
- 6
- 37
- 59
1 Answers
28
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.

Darrarski
- 3,882
- 6
- 37
- 59
-
Could you please help me out on one issue. Actually I have a view with certain dimensions 817x460, I have objects in that view like NSButton,NSImageView etc. But when I maximise the view, the objects are not getting stretched, i.e. the size is constant even upon using auto-layout and your solution. Could you please tell me how to enlarge the views and objects to make it compatible with window size. Please help me, thanks :) – Eshwar Chaitanya Aug 01 '14 at 11:44