O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required