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