up

Views and Gestures

Views

Initializing a UIView

View Coordinates

Coordinates

Creating Views

Custom Views

Context

Define a Path

Graphics State

View Transparency

Graphics State Context

Drawing Text

Drawing Images

Redraw on Bounds Change

UIGestureRecognizer

UIGestureRecognizer

Other Concrete Gestures

Demo

Adding a swipe gesture can be done from the interface builder in xcode, search for "gesture" in the object library and drag a swipe gesture onto your target, then ctrl click and drag from the gesture recognizer icon that appears in the View Controllers menu box, into your view controller files implementation, to generate and link an action for the gesture.

Or it can be done in code:

// This action is added to the target view, in which the scale factor is used
// in scaling the presentation of the contents of the view.
- (void)pinch:(UIPinchGestureRecognizer *)gesture
{
    if ((gesture.state == UIGestureRecognizerStateChanged) ||
        (gesture.state == UIGestureRecognizerStateEnded)) {
        self.faceCardScaleFactor *= gesture.scale;
        gesture.scale = 1.0;
    }
}

// The gesture is added to the scenes View Controller once it has loaded.
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.playingCardView addGestureRecognizer:[[UIPinchGestureRecognizer alloc]
                                initWithTarget:self.playingCardView
                                        action:@selector(pinch:)]];
}