NSImageView and window resizing

I have a Cocoa application. In the window window I placed NSImageView. Using automatic layout, I added the start and end spaces so that the NSImageView is anchored to the view (and therefore to the window).

The NSImageView scaling property is set to ScaleDown.

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

The problem is that I am making the window smaller. Everything works until I hit the image size. Then I can not make the window smaller.

In other words, I can only make a window the size of an image. What I want - and expected using the ScaleDown parameter - is to zoom out using the window.

+4
source share
1 answer

Image compression resilience priority is higher than NSLayoutPriorityWindowSizeStayPut(500). Thus, the compression resistance of the image prevents window resizing.

Omit this priority of resistance.

+15
source

Source: https://habr.com/ru/post/1545338/


All Articles