开发者

Animate two views like when you pass a phone call

I have made many tries to have the same effect of switch than the one you can see when calling a phone number : the front view disapear with a zoom effect, while the other one appears also with a zoom effect.

I can't achieve doing that effect, it's always a so-so. There seems to have a scale effect, with an action on opacity, but...

Do you know how this can be done to reflect that effect (not a so-so, I have tons开发者_高级运维 of those) ?


 // Make this interesting.

 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:2.0];
 [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
 [UIView setAnimationDelegate:self]; 
 [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
 self.view.alpha = 0.0;
 self.view.frame = CGRectMake(self.view.center.x,self.view.center.y , 0, 0);
 [UIView commitAnimations];
}

I hope this is a framework for a better animation. It's not guaranteed to work, but it's the best I could think of for the first part of the transition.

This will change the frame of your view controller's view so that it "sucks" itself into the center of the screen, which is a natural black color. Now that I think about it, a CGAffineTransform would have been much easier...

EDIT (For pedantry's sake): Starting with iOS 4, you can now use the newer, and much more syntactically clean, animation blocks and a nice transform:

[UIView animateWithDuration:0.25 delay:0.0 options:0 animations:^{
     //animate the toolbars in from the top and bottom
     [myTopView setFrame:CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44)];
     [myBottomView setFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
     //fade to black...
     self.view.alpha = 0.0;
     //and suck inwards.
     self.view.frame = CGRectMake(self.view.center.x,self.view.center.y , 0, 0);
}
completion:^{
    //do something to end nicely, or start another animation block.
}];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜