如何在基于导航的应用程序中更改Push和Pop动画

如何在基于导航的应用程序中更改Push和Pop动画

我有一个基于导航的应用程序,我想改变动画的推送和流行动画。我该怎么做?

这个问题有很多答案,现在已经有很长一段时间了,我重新选择了我认为最相关的答案。如果有人不这么认为,请在评论中告诉我。


MYYA
浏览 680回答 3
3回答

守候你守候我

我做了以下工作,效果很好.简单易懂。CATransition* transition = [CATransition animation]; transition.duration = 0.5; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionFade;  //kCATransitionMoveIn;  //, kCATransitionPush, kCATransitionReveal, kCATransitionFade  //transition.subtype = kCATransitionFromTop;   //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom[self.navigationController.view.layer a  ddAnimation:transition forKey:nil];[[self navigationController] popViewControllerAnimated:NO];对推也是一样的.。SWIFT 3.0版本:let transition = CATransition()transition.duration = 0.5transition.timingFunction = CAMediaTimingFunction(name:  kCAMediaTimingFunctionEaseInEaseOut)transition.type = kCATransitionFadeself.navigationController?.view.layer.add(transition, for Key: nil)_ = self.navigationController?.popToRootViewController(animated: false)

冉冉说

我一直都是这样完成这个任务的。用于推送:MainView *nextView=[[MainView alloc] init];[UIView  beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.75];[self.navigationController pushViewController:nextView animated:NO]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];[UIView commitAnimations]; [nextView release];关于POP:[UIView  beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.75];[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView: self.navigationController.view cache:NO];[UIView commitAnimations];[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelay:0.375];[self.navigationController popViewControllerAnimated:NO];[UIView commitAnimations];我仍然从这得到了很多反馈,所以我将继续更新它,以使用动画块,这是苹果推荐的方式来做动画无论如何。用于推送:MainView *nextView = [[MainView alloc] init];[UIView animateWithDuration:0.75                          animations:^{                              [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];                              [self.navigationController pushViewController:nextView animated:NO];     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];                          }];关于POP:[UIView animateWithDuration:0.75                          animations:^{                              [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];                [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];                          }];[self.navigationController popViewControllerAnimated:NO];
打开App,查看更多内容
随时随地看视频慕课网APP