5. Drawing Custom Views

In this chapter, we will build a simple line graph that shows how the user’s weight changes over time. Both the weight axis and the time axis will scale to fill all available space. We will also draw labeled reference lines to help the user interpret the graph.

Most of this chapter focuses on performing custom drawing within our UIViews. We will look both at UIKit’s drawing methods and at the underlying Core Graphics framework. We will also examine how the iOS SDK manages the difference in resolution between regular and Retina displays.

Building GraphStats

Let’s start by creating the GraphStats class. This class will process an array of WeightEntries and calculate some simple statistics about the collection. These include: ...

Get Creating iOS 5 Apps: Develop and Design now with O’Reilly online learning.

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