iPhone Developer : Assembling Views and Animations - Recipe: Swapping Views

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

The UIView animation block doesn’t limit you to a single change. Recipe 1 combines size transformations with transparency changes to create a more compelling animation. It does this by adding several directives at once to the animation block. This recipe performs five actions at a time. It zooms and fades one view into place while zooming out and fading away another and then exchanges the two in the subview array list.

Notice how the viewDidLoad method prepares the back object for animation by shrinking it and making it transparent. When the swap: method first executes, that view will be ready to appear and zoom to size.

This recipe does wait for the animation to finish by providing a delegate and a simplified callback that ignores the parameters of the default callback invocation (animationDidStop:finished:context:). This code hides the bar button after it is pressed and does not return it to view until the animation completes.

Recipe 1. Combining Multiple View Changes in Animation Blocks
- (void) animationFinished: (id) sender
self.navigationItem.rightBarButtonItem =

- (void) swap: (id) sender
self.navigationItem.rightBarButtonItem = nil;

UIView *frontObject = [[self.view subviews] objectAtIndex:2];
UIView *backObject = [[self.view subviews] objectAtIndex:1];

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];

frontObject.alpha = 0.0f;
backObject.alpha = 1.0f;
frontObject.transform = CGAffineTransformMakeScale(0.25f, 0.25f);
backObject.transform = CGAffineTransformIdentity;
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:2];
[UIView setAnimationDelegate:self];
Soccer Highlights
- VIDEO Lyon 4 – 0 Apollon Limassol (Europa League) Highlights
- VIDEO Everton 1 – 5 Atalanta (Europa League) Highlights
- VIDEO AC Milan 5 – 1 Austria Wien (Europa League) Highlights
- VIDEO FC Cologne 1 – 0 Arsenal (Europa League) Highlights
- VIDEO Nice 3 – 1 Zulte-Waregem (Europa League) Highlights
- VIDEO Braga 3 – 1 Hoffenheim (Europa League) Highlights
- VIDEO Lazio 1 – 1 Vitesse (Europa League) Highlights
- VIDEO Konyaspor 1 – 1 Marseille (Europa League) Highlights
- VIDEO Athletic Bilbao 3 – 2 Hertha Berlin (Europa League) Highlights
- VIDEO Salzburg 3 – 0 Vitoria de Guimaraes (Europa League) Highlights
- VIDEO Ludogorets Razgrad 1 – 2 Istanbul Basaksehir (Europa League) Highlights
- VIDEO FC Astana 2 – 3 Villarreal (Europa League) Highlights
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us