IOS4 note 16 (chapter 15) Drawing

Drawing

Many UIView subclasses, such as a UIButton or a UITextField, know how  to draw themselves.

Drawing is not difficult, but it is a very large topic. There are some UIKit convenience methods, but the full API is provided by Core Graphics, often referred to as Quartz, or Quartz 2D. Core Graphics  is  the drawing  system  that underlies all  iOS drawing - UIKit drawing is built on top of it - so it is low-level and consists of C functions, but it isn’t entirely alien. This chapter will familiarize you with the fundamentals. For complete information, you’ll want to study Apple’s Quartz 2D Programming Guide.

UIImageView draws an image for you and takes care of all the details. If you want to do any drawing for yourself, however, you must do so in a graphics context. A graphics context is basically a place you can draw. In certain situations, a graphics context is provided for you; otherwise, you must obtain or create one for yourself. Either way, this graphics context may also become the current context. Core Graphics drawing functions require that you specify a context to draw into; UIKit’s Objective-C drawing methods typically draw into the current context. If you have a context that you want to draw into and it isn’t the current context, you can make it the current context temporarily by calling UIGraphicsPushContext (and be sure to restore things with UIGraphicsPopContext later). 

 

 

 

你可能感兴趣的:(IOS4 note 16 (chapter 15) Drawing)