Question

Can anyone please suggest me a good sample code for zooming image in NSImageView. Thanks.

Was it helpful?

Solution

If you look at the documentation, you'll see that NSImageView doesn't support this. Use Image Kit instead.

OTHER TIPS

Perhaps you want to try using ImageKit's IKImageView instead. This gives you zooming, rotation, etc...all for free.

While technically NSImageView doesn't technically support this, it is possible. I believe by changing the bounds of the NSView that you're using, and make sure that the image is set to "Proportionally Down", or "Proportionally Up or Down".

This code seems to work for me, on OSX 10.9 (Mavericks)

   NSSize size = [_imageView bounds].size;

   NSSize newSize = NSMakeSize(size.width * 0.90, size.height * 0.90);

   [_imageView setBoundsSize: newSize];

I have also had success "embedding" an image view inside a scroll view, and then using magnification on the scroll view. YMMV

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top