iPhone Code Schnipsel: Subviews umdrehen

Gegeben

Ein Fenster mit zwei Subviews:

[window addSubview:view1];
[window addSubview:view2];

Gesucht

Zwischen den Views wechseln und dabei eine Animation anzeigen, die ein Umdrehen symbolisiert.

Lösung

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[window exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
[UIView commitAnimations];

Will man von rechts nach links drehen, nimmt man UIViewAnimationTransitionFlipFromRight statt dem obigen UIViewAnimationTransitionFlipFromLeft.

Schlüsselwörter: iphone, objective-c, programmierung, schnipsel

Von Thomas Dohmke vor 546 Tagen hinzugefügt


Kommentare

Kommentar hinzufügen

Twitter

Uns auf Twitter verfolgen: