Can't believe there is no built-in Aspect Fit scaling method for the NSImageView class. I'm looking for the same behaviour as when using Preview.app with "Zoom to fit" turned on. Do I have to implement the scaling algorithm on my own or is there any trick shorthand?
Asked
Active
Viewed 1,313 times
4
-
Have you tried setting imageScaling to `NSImageScaleProportionallyUpOrDown`? Does that not work as expected? – dave Mar 23 '15 at 19:36
-
NSImageScaleProportionallyUpOrDown does not resize the image to "aspect fit" the container, instead it will be resized so it always completely fills the container - it's the same behaviour as "background-size: cover" does in CSS - I'm looking for "background-size: contain" instead. – riccardolardi Mar 25 '15 at 11:05
-
1Weird thing - It seems as when the ImageCell's frame property is set to anything but none the resizing will work as expected. Is this a bug? Can anyone confirm this? – riccardolardi Mar 25 '15 at 18:15
-
Looking for this too! Any luck @alberto2000 ? – justColbs Jun 03 '15 at 17:18
-
1@justColbs: Yeah I sorted it but I'm not sure exactly how to be honest - after trying out different things it suddenly worked - try this on the imageView: setImageFrameStyle:NSImageFramePhoto - please report if it helped! – riccardolardi Jun 03 '15 at 19:28
-
@alberto2000 That did not work. setting the NSImageFrameStyle doesn't do anything with scaling the image it seems. I actually need to set the NSImageView's background color. That is what I'm trying to figure out now. Thanks for the suggestion! – justColbs Jun 04 '15 at 22:01