Chapter 10. Applying Custom UIViews
In This Chapter
Working within the Cocoa Touch view geometry |
Adding a custom view to an interface |
Exploring Core Graphics |
Using basic drawing commands |
In this chapter, we're going to return to the Model, View, Controller design pattern, and focus on one particular component of this pattern, views. Every graphical component that you use in building your applications inherits from UIView
, the Cocoa Touch class that represents the View part of the Model, View, Controller pattern. This means that understanding this fundamental component is vital to your success on the platform.
Doing custom drawing is one of the most common requirements when creating custom UIViews
. One of the most powerful things that Cocoa Touch inherits from its Cocoa lineage is its drawing API. When it was originally developed, this drawing API, known as Core Graphics, was unparalleled for its ease of use and capabilities. Even now, through its acceleration with OpenGL, it provides an excellent way to draw custom 2-D graphics on the screen.
In addition to its outstanding abilities when it comes to drawing graphics, UIView
also provides some simplified mechanisms for doing basic animation using Core Animation.
In this chapter, you are going to take a look at how to add custom UIViews
to your projects and then how to draw graphics in those views.
Understanding Cocoa Touch View Geometry
The first thing to understand about using UIViews
is how the Cocoa Touch view geometry works. Figure 10.1 ...
Get Cocoa Touch™ for iPhone® OS 3 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.