Stretch PNGs smoothly in Cocoa AppKit

cocoa, objective-c

Solution

Use `NSDrawThreePartImage` or `NSDrawNinePartImage`.

Problem

In questions like this one it shows how to use UIKit's ``` -(UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight ``` to stretch a PNG easily, e.g when inserting text in an iChat like bubble. I would like to do the same on regular AppKit/Cocoa/desktop app using CoreGraphics or some NSImage related API but couldn't find an equivalent method. Does anybody know how to do this in AppKit?

Original source

Related problems