Core Graphics

The functions and types that begin with CG come from the Core Graphics framework, a C language API for 2D drawing. The hub of the Core Graphics framework is CGContextRef: all other Core Graphics functions and types interact with a drawing context in some way, and then the context creates an image.

Let’s look at the Core Graphics functions you used in the implementation of HypnosisView’s drawRect: method. You set up the drawing state with CGContextSetLineWidth and then set its color using CGContextSetRGBStrokeColor.

Next, you added a path to the context using CGContextAddArc. A path is a collection of points that forms a shape and can form anything from a square to a circle to a human outline. There are a number of Core Graphics ...

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.