Search code examples
macoscocoansimagepanzooming

How to PAN and ZOOM NSImages for a Cocoa MAC OS application?


As the title says, I want to be able to PAN images (NSImages) with a mouse cursor, and ZOOM images in any way. How can I do that as I can't find any resources online, someone please help!


Solution

  • You should take a look at using Apples's IKImageView.

    The IKImageView class provides an efficient way to display images in a view while at the same time supporting a number of image editing operations such as rotating, zooming, and cropping. It supports drag and drop, so that the user can drag an image to the view. If possible, image rendering uses hardware acceleration to achieve optimal performance. The IKImageView class is implemented as a subclass of NSView. Similar to NSImageView, the IKImageView class is used to display a single image.

    IKImageView has some shortcomings, but in my experience zooming works well.