Quartz 2D Shadings
Version 1.0, 2007-08-31
Shows how to use CGShading and CGGradient objects to draw simple gradients.
Mac OS X 10.5 and Xcode 3.0
Mac OS X 10.5
Quartz 2D Shadings demonstrates how to create gradient fills using both the new CGGradientRef objects introduced in Mac OS X 10.5 and using the older CGShadingRef and CGFunctionRef objects available since Mac OS X 10.2. In this sample, both object types are used to obtain identical results, demonstrating how CGGradientRef objects are easier to use than CGShadingRef objects. In general CGShadingRef objects are more flexible, capable of creating shadings that a CGGradientRef object cannot. If you need a linear gradient, then it is much simpler to use a CGGradientRef object. If you need to create non-linear gradients, or some other kind of custom blending, then CGShadingRef objects will allow you to express such gradients, as they use user specified CGFunctionRef object to generate their colors.