Version: 1.0

Posted: 2007-08-31

Build Requirements: Mac OS X 10.5 and Xcode 3.0

Runtime Requirements: Mac OS X 10.5

View Source Code:

Download Sample (“Quartz2DShadings.zip”, 193.7K)
Download Sample (“Quartz2DShadings.dmg”, 259.8K)



Description

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 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.

Document Revision History

Date Notes
2007-08-31Shows how to use CGShading and CGGradient objects to draw simple gradients.

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.