View object

A view is an object that draws itself within a rectangular area of a window and that can respond to user actions such as finger taps or mouse clicks. A view draws a visual representation of itself and presents a surface that responds to touches and input from devices. Not all views handle events, but views are more likely to handle events than other types of responder objects (that is, objects capable of responding to events). Views also provide the content for printing. For a view to be useful, it must be situated in the view hierarchy of a window.

Views inherit, directly or indirectly, from NSView in Mac OSX or from UIView in iOS. These classes perform no drawing or event-handling themselves, but provide the interface and infrastructure for subclasses. The AppKit and UIKit frameworks provide almost all views that you see in an application’s window, including buttons, table views, text fields, toolbars, and sliders. These views are available to your project in the Interface Builder library. You can also subclass UIView or NSView and create custom views that draw themselves and handle events in distinctive ways.

The Core Properties of Views

Views in both the UIKit and AppKit frameworks have important characteristics defined by a handful of properties:

Views Are Inherently Capable of Animation

In both iOS and Mac OS X, each view is (or can be) backed by a Core Animation layer object (CALayer), which is accessible through the layer property. The layer object caches a view’s drawing content, assists in the layout and rendering of that content, and can composite and animate that content. Certain properties of a view, such as the view’s frame and its opacity, are implicitly capable of animation. In addition, an application may explicitly animate a view using facilities of the Core Animation framework.

In Mac OS X, CALayer-support is optional whereas in iOS this support is built into each view’s rendering implementation.

Definitive Discussion

Prerequisite Articles

    (None)

Sample Code Projects

    (None)

Did this document help you? Yes It's good, but... Not helpful...


Last updated: 2010-07-07