For the More Curious: Core Graphics

In general, the drawRect: method uses UIImage, UIBezierPath, and NSString instances to draw images, shapes, and text, respectively. Each of these classes implements at least one method that, when executed in drawRect:, draws pixels to the layer of the view that was sent drawRect:.

These classes make iOS drawing look simple and convenient. However, there is a lot going on underneath the hood.

Drawing images in iOS – whether it is an image you will save as a JPEG or PDF or a layer that represents a UIView – is the responsibility of the Core Graphics framework. The classes that you used to perform drawing in this chapter, like UIBezierPath, wrap Core Graphics code into their methods to ease drawing ...

Get iOS Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.