Chapter 10. Custom Views and Drawing
If you’re looking to get started with graphics programming, you’ve come to the right place. Mac OS X has a lot of graphics frameworks to choose from, and each one specializes in something different. Here’s a quick rundown of the main players:
- AppKit
The UI part of Cocoa has classes and methods for dealing with colors, geometry, styled text, bitmap images, and complex paths. This is the first place you should start when writing custom drawing code for the Mac UI.
- Core Graphics
This is the lower-level, C-based framework for 2D drawing in Mac OS X. Core Graphics is also part of the iPhone SDK, so you can share code easily. The drawback is that the C functions and memory management are not as convenient or as flexible as the Objective-C AppKit drawing classes.
- Core Animation
This is a relatively new framework that’s part of both Mac OS X and the iPhone OS. It’s based on OpenGL and allows you to use a lot of impressive 3D and transition effects, but it has an easy-to-use Objective-C interface. Because it uses the GPU, it’s incredibly fast. You can also combine Core Animation with AppKit in certain cases.
- Core Image
This framework allows you to apply special effects to your images and views, such as Gaussian Blur, bloom, color adjustments, and even transitions like page curls and dissolves. This isn’t an API that’s useful for general drawing. Instead, you usually combine it with another framework. Core Image is currently not available in the iPhone SDK.
It’s ...
Get Cocoa and Objective-C: Up and Running now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.