Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSImageView and resizing of window

I have a Cocoa application. In the window's view I have placed an NSImageView. Using auto layout I have added leading and trailing spaces in such a way that the NSImageView is anchored to the view (and thus window).

The NSImageView's scaling property have been set to ScaleDown.

When I make the window larger, everything happens as expected. The image is centered in the window and does not scale up.

The problem is when I make the window smaller. Everything works until I hit the image's size. Then I can't make the window any smaller.

In other words I can only make the window as small as the image's size. What I want - and did expect by using the ScaleDown setting - is to have the image scale down with the window.

like image 687
Jacob Rohde Avatar asked Jun 20 '14 08:06

Jacob Rohde


1 Answers

The image view's compression resistance priority is higher than NSLayoutPriorityWindowSizeStayPut (500). So, the image view's resistance to being compressed prevents the window from resizing.

Lower that resistance priority.

like image 174
Ken Thomases Avatar answered Oct 23 '22 08:10

Ken Thomases