Can anyone please suggest me a good sample code for zooming image in NSImageView. Thanks.
If you look at the documentation, you'll see that NSImageView doesn't support this. Use Image Kit instead.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With