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
Schlüsselwörter
- berlin (2)
- blog (5)
- browser (2)
- cocoaheads (5)
- dropbox (1)
- git (7)
- idisk (1)
- iphone (28)
- javascript (2)
- kurztip (4)
- linktips (17)
- mac (9)
- macruby (1)
- objective-c (8)
- ortung (1)
- programmierung (22)
- rails (1)
- railsconf (7)
- ruby (6)
- ruby on rails (7)
- schnipsel (14)
- server (2)
- spiele (1)
- statistiken (3)
- stuttgart (3)
- testen (4)
- tidy (1)
- versionskontrolle (5)
- wwdc (1)
- xcode (9)
- xml (1)
Kommentare