/* * @DO 视图切换动画 * @param sender(id) */ - (void) switchViews:(id)sender { // 准备动画 // [UIView beginAnimations:@"Curl"context:nil]; // 动画播放持续时间 // [UIView setAnimationDuration:1.25]; // 动画速度 // [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; // 准备动画 CATransition *animation = [CATransition animation]; //动画播放持续时间 [animation setDuration:0.25f]; //动画速度,何时快、慢 [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; if (self.showViewController.view.superview == nil) { // 动画方向 // [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp // forView:self.view cache:YES]; /*动画效果 ( kCATransitionFade淡出| kCATransitionMoveIn覆盖原图| kCATransitionPush推出| kCATransitionReveal底部显出来 ) */ [animation setType:kCATransitionReveal]; /*动画方向 ( kCATransitionFromRight| kCATransitionFromLeft| kCATransitionFromTop| kCATransitionFromBottom ) */ [animation setSubtype:kCATransitionFromBottom]; [self.view.layer addAnimation:animation forKey:@"Reveal"]; [saveViewController.view removeFromSuperview]; [self.view insertSubview:showViewController.viewatIndex:0]; } else { // 动画方向 // [UIView setAnimationTransition: UIViewAnimationTransitionCurlDown // forView:self.view cache:YES]; /*动画效果 ( suckEffect三角| rippleEffect水波| pageCurl上翻页| pageUnCurl下翻页| oglFlip上下翻转| ) */ [animation setType:@"suckEffect"]; //开始动画 [self.view.layer addAnimation:animation forKey:@"suckEffect"]; [showViewController.view removeFromSuperview]; [self.view insertSubview:saveViewController.view atIndex:0]; } // 结束动画 // [UIView commitAnimations]; } |