I'm creating an app that must run on Tiger and I need to draw a gradient onto a NSView. Unfortunately, NSGradient is only available on Leopard and above. Google wasn't my friend at all. How do I draw a gradient to a NSView on Mac OS X 10.4?
Thanks!
I'm creating an app that must run on Tiger and I need to draw a gradient onto a NSView. Unfortunately, NSGradient is only available on Leopard and above. Google wasn't my friend at all. How do I draw a gradient to a NSView on Mac OS X 10.4?
Thanks!
A lot of developers used CTGradient
before Apple introduced NSGradient
. It's a wrapper around the CGShading
C API.
You will need to use a CGShading
object to draw the gradient, and write the interpolation function for it yourself (an example is given in the Quartz 2D Programming Guide).