ios 如何在基于导航的应用程序中更改推送和弹出动画
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2215672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the Push and Pop animations in a navigation based app
提问by Jab
I have a navigation based application and I want to change the animation of the push and pop animations. How would I do that?
我有一个基于导航的应用程序,我想更改推送和弹出动画的动画。我该怎么做?
Edit 2018
编辑 2018
There have been many answers to this question and it's been quite awhile now, I have re-chosen the answer to what I believe to be the most relevant now. If there is anyone that thinks otherwise please let me know in comments
这个问题有很多答案,现在已经有一段时间了,我重新选择了我认为现在最相关的答案。如果有人不这么认为,请在评论中告诉我
采纳答案by Fattie
How to change the Push and Pop animations in a navigation based app...
如何在基于导航的应用程序中更改推送和弹出动画...
For 2019, the "final answer!"
2019年,“最终答案!”
Preamble:
前言:
Say you are new to iOS development. Confusingly, Apple provide two transitions which can be used easily. These are: "crossfade" and "flip".
假设您是 iOS 开发的新手。令人困惑的是,Apple 提供了两种易于使用的过渡。它们是:“交叉淡入淡出”和“翻转”。
But of course, "crossfade" and "flip" are useless. They are never used. Nobody knows why Apple provided those two useless transitions!
但当然,“交叉淡入淡出”和“翻转”是没有用的。它们从不使用。没有人知道为什么 Apple 提供了这两个无用的过渡!
So:
所以:
Say you want to do an ordinary, common, transitionsuch as "slide". In that case, you have to do a HUGE amount of work!.
假设你想做一个普通的、常见的、过渡,比如“幻灯片”。在这种情况下,您必须做大量的工作!.
That work, is explained in this post.
这项工作在这篇文章中有解释。
Just to repeat:
重复一遍:
Surprisingly: with iOS, if you want the simplest, most common, everyday transitions(such as an ordinary slide), you do have to all the workof implementing a full custom transition.
令人惊讶的是:在 iOS 中,如果您想要最简单、最常见的日常过渡(例如普通幻灯片),则必须完成实现完全自定义过渡的所有工作。
Here's how to do it ...
这是如何做到的......
1. You need a custom UIViewControllerAnimatedTransitioning
1.你需要定制 UIViewControllerAnimatedTransitioning
You need a bool of your own like
popStyle
. (Is it popping on, or popping off?)You must include
transitionDuration
(trivial) and the main call,animateTransition
In fact you mustwrite two different routines for inside
animateTransition
. One for the push, and one for the pop. Probably name themanimatePush
andanimatePop
. InsideanimateTransition
, just branch onpopStyle
to the two routinesThe example below does a simple move-over/move-off
In your
animatePush
andanimatePop
routines. You mustget the "from view" and the "to view". (How to do that, is shown in the code example.)and you must
addSubview
for the new "to" view.and you mustcall
completeTransition
at the end of your anime
你需要一个自己喜欢的 bool
popStyle
。(它是弹出还是弹出?)你必须包括
transitionDuration
(trivial) 和 main 调用,animateTransition
实际上,您必须为 inside 编写两个不同的例程
animateTransition
。一种用于推动,一种用于流行。可能命名它们animatePush
和animatePop
。在里面animateTransition
,只是分支popStyle
到两个例程下面的例子做了一个简单的移动/移动
在你
animatePush
和animatePop
例程。您必须获得“从视图”和“从视图”。(如何做到这一点,在代码示例中显示。)并且您必须
addSubview
使用新的“to”视图。你必须
completeTransition
在你的动画结束时打电话
So ..
所以 ..
class SimpleOver: NSObject, UIViewControllerAnimatedTransitioning {
var popStyle: Bool = false
func transitionDuration(
using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.20
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
if popStyle {
animatePop(using: transitionContext)
return
}
let fz = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let tz = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let f = transitionContext.finalFrame(for: tz)
let fOff = f.offsetBy(dx: f.width, dy: 55)
tz.view.frame = fOff
transitionContext.containerView.insertSubview(tz.view, aboveSubview: fz.view)
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
animations: {
tz.view.frame = f
}, completion: {_ in
transitionContext.completeTransition(true)
})
}
func animatePop(using transitionContext: UIViewControllerContextTransitioning) {
let fz = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let tz = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let f = transitionContext.initialFrame(for: fz)
let fOffPop = f.offsetBy(dx: f.width, dy: 55)
transitionContext.containerView.insertSubview(tz.view, belowSubview: fz.view)
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
animations: {
fz.view.frame = fOffPop
}, completion: {_ in
transitionContext.completeTransition(true)
})
}
}
And then ...
进而 ...
2. Use it in your view controller.
2. 在你的视图控制器中使用它。
Note: strangely, you only have to do thisin the "first" view controller. (The one which is "underneath".)
注意:奇怪的是,您只需在“第一个”视图控制器中执行此操作。(在“下面”的那个。)
With the one that you pop on top, do nothing. Easy.
与你弹出的一个顶部,做什么。简单。
So your class...
所以你的课...
class SomeScreen: UIViewController {
}
becomes...
变成……
class FrontScreen: UIViewController,
UIViewControllerTransitioningDelegate, UINavigationControllerDelegate {
let simpleOver = SimpleOver()
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.delegate = self
}
func navigationController(
_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationControllerOperation,
from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
simpleOver.popStyle = (operation == .pop)
return simpleOver
}
}
That's it.
就是这样。
Push and pop exactly as normal, no change. To push ...
完全像往常一样推动和弹出,没有变化。要推...
let n = UIStoryboard(name: "nextScreenStoryboardName", bundle: nil)
.instantiateViewController(withIdentifier: "nextScreenStoryboardID")
as! NextScreen
navigationController?.pushViewController(n, animated: true)
and to pop it, you can if you like just do that on the next screen:
并弹出它,如果您愿意,可以在下一个屏幕上执行此操作:
class NextScreen: TotallyOrdinaryUIViewController {
@IBAction func userClickedBackOrDismissOrSomethingLikeThat() {
navigationController?.popViewController(animated: true)
}
}
Phew.
呼。
3. Also enjoy the other answers on this page which explain how to override AnimatedTransitioning
3. 还可以享受此页面上的其他答案,其中解释了如何覆盖 AnimatedTransitioning
Scroll to @AlanZeino and @elias answer for more discussion on how to AnimatedTransitioning
in iOS apps these days!
滚动到@AlanZeino 和@elias 的答案,以了解有关如何AnimatedTransitioning
在 iOS 应用程序中使用这些天的更多讨论!
回答by Magnus
I did the following and it works fine.. and is simple and easy to understand..
我做了以下操作,效果很好..而且简单易懂..
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 addAnimation:transition forKey:nil];
[[self navigationController] popViewControllerAnimated:NO];
And the same thing for push..
和推同样的事情..
Swift 3.0 version:
斯威夫特 3.0 版本:
let transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionFade
self.navigationController?.view.layer.add(transition, forKey: nil)
_ = self.navigationController?.popToRootViewController(animated: false)
回答by jordanperry
This is how I've always managed to complete this task.
这就是我一直设法完成这项任务的方式。
For Push:
对于推送:
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];
For 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];
I still get a lot of feedback from this so I'm going to go ahead and update it to use animation blocks which is the Apple recommended way to do animations anyway.
For Push:
我仍然从中得到很多反馈,所以我将继续更新它以使用动画块,这是 Apple 推荐的动画制作方式。
对于推送:
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];
}];
For Pop:
流行音乐:
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
}];
[self.navigationController popViewControllerAnimated:NO];
回答by Ted
for push
推
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionFade;
//transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:ViewControllerYouWantToPush animated:NO];
for pop
流行音乐
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionFade;
//transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController popViewControllerAnimated:NO];
回答by CularBytes
@Magnus answer, only then for Swift (2.0)
@Magnus 回答,仅适用于 Swift (2.0)
let transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromTop
self.navigationController!.view.layer.addAnimation(transition, forKey: nil)
let writeView : WriteViewController = self.storyboard?.instantiateViewControllerWithIdentifier("WriteView") as! WriteViewController
self.navigationController?.pushViewController(writeView, animated: false)
Some sidenotes:
一些旁注:
You can do this as well with Segue, just implement this in prepareForSegue
or shouldPerformSegueWithIdentifier
. However, this will keep the default animation in it as well. To fix this you have to go to the storyboard, click the Segue, and uncheck the box 'Animates'. But this will limit your app for IOS 9.0 and above (atleast when I did it in Xcode 7).
你也可以用 Segue 做到这一点,只需在prepareForSegue
或 中实现shouldPerformSegueWithIdentifier
。但是,这也将保留默认动画。要解决此问题,您必须转到情节提要,单击 Segue,然后取消选中“动画”框。但这会限制您的应用程序在 IOS 9.0 及更高版本上运行(至少当我在 Xcode 7 中这样做时)。
When doing in a segue, the last two lines should be replaced with:
在执行 segue 时,最后两行应替换为:
self.navigationController?.popViewControllerAnimated(false)
Even though I set false, it kind of ignores it.
即使我设置了 false,它也会忽略它。
回答by Luca Davanzo
Remember that in Swift, extensionare definitely your friends!
请记住,在Swift 中, 扩展绝对是您的朋友!
public extension UINavigationController {
/**
Pop current view controller to previous view controller.
- parameter type: transition animation type.
- parameter duration: transition animation duration.
*/
func pop(transitionType type: String = kCATransitionFade, duration: CFTimeInterval = 0.3) {
self.addTransition(transitionType: type, duration: duration)
self.popViewControllerAnimated(false)
}
/**
Push a new view controller on the view controllers's stack.
- parameter vc: view controller to push.
- parameter type: transition animation type.
- parameter duration: transition animation duration.
*/
func push(viewController vc: UIViewController, transitionType type: String = kCATransitionFade, duration: CFTimeInterval = 0.3) {
self.addTransition(transitionType: type, duration: duration)
self.pushViewController(vc, animated: false)
}
private func addTransition(transitionType type: String = kCATransitionFade, duration: CFTimeInterval = 0.3) {
let transition = CATransition()
transition.duration = duration
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = type
self.view.layer.addAnimation(transition, forKey: nil)
}
}
回答by nicktmro
Using private calls is a bad idea as Apple no longer approve apps that do that. Maybe you could try this:
使用私人电话是一个坏主意,因为 Apple 不再批准这样做的应用程序。也许你可以试试这个:
//Init Animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.50];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES];
//Create ViewController
MyViewController *myVC = [[MyViewController alloc] initWith...];
[self.navigationController pushViewController:myVC animated:NO];
[myVC release];
//Start Animation
[UIView commitAnimations];
回答by Alan Zeino
Since this is the top result on Google I thought I'd share what I think is the most sane way; which is to use the iOS 7+ transitioning API. I implemented this for iOS 10 with Swift 3.
由于这是 Google 上的最高结果,我想我会分享我认为最明智的方法;这是使用 iOS 7+ 转换 API。我用 Swift 3 为 iOS 10 实现了这个。
It's pretty simple to combine this with how UINavigationController
animates between two view controllers if you create a subclass of UINavigationController
and return an instance of a class that conforms to the UIViewControllerAnimatedTransitioning
protocol.
UINavigationController
如果您创建UINavigationController
符合UIViewControllerAnimatedTransitioning
协议的类的子类并返回该类的实例,那么将其与两个视图控制器之间的动画方式结合起来非常简单。
For example here is my UINavigationController
subclass:
例如这里是我的UINavigationController
子类:
class NavigationController: UINavigationController {
init() {
super.init(nibName: nil, bundle: nil)
delegate = self
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension NavigationController: UINavigationControllerDelegate {
public func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return NavigationControllerAnimation(operation: operation)
}
}
You can see that I set the UINavigationControllerDelegate
to itself, and in an extension on my subclass I implement the method in UINavigationControllerDelegate
that allows you to return a custom animation controller (i.e., NavigationControllerAnimation
). This custom animation controller will replace the stock animation for you.
您可以看到我将 设置UINavigationControllerDelegate
为自身,并且在我的子类的扩展中我实现了UINavigationControllerDelegate
允许您返回自定义动画控制器(即NavigationControllerAnimation
)的方法。这个自定义动画控制器将为您替换库存动画。
You're probably wondering why I pass in the operation to the NavigationControllerAnimation
instance via its initializer. I do this so that in NavigationControllerAnimation
's implementation of the UIViewControllerAnimatedTransitioning
protocol I know what the operation is (i.e., 'push' or 'pop'). This helps to know what kind of animation I should do. Most of the time, you want to perform a different animation depending on the operation.
您可能想知道为什么我NavigationControllerAnimation
通过它的初始化程序将操作传递给实例。我这样做是为了在协议NavigationControllerAnimation
的实现中UIViewControllerAnimatedTransitioning
我知道操作是什么(即“推送”或“弹出”)。这有助于了解我应该做什么样的动画。大多数情况下,您希望根据操作执行不同的动画。
The rest is pretty standard. Implement the two required functions in the UIViewControllerAnimatedTransitioning
protocol and animate however you like:
其余的都很标准。在UIViewControllerAnimatedTransitioning
协议中实现两个必需的功能并根据需要制作动画:
class NavigationControllerAnimation: NSObject, UIViewControllerAnimatedTransitioning {
let operation: UINavigationControllerOperation
init(operation: UINavigationControllerOperation) {
self.operation = operation
super.init()
}
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.3
}
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),
let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) else { return }
let containerView = transitionContext.containerView
if operation == .push {
// do your animation for push
} else if operation == .pop {
// do your animation for pop
}
}
}
It's important to remember, that for each different type of operation (i.e., 'push' or 'pop), the to and from view controllers will be different. When you are in a push operation, the to view controller will be the one being pushed. When you are in a pop operation, the to view controller will be the one that is being transitioned to, and the from view controller will be the one that's being popped.
重要的是要记住,对于每种不同类型的操作(即“推送”或“弹出”),to 和 from 视图控制器将是不同的。当您进行推送操作时,视图控制器将是被推送的控制器。当您进行弹出操作时,to 视图控制器将是被转换到的视图控制器,而 from 视图控制器将是被弹出的视图控制器。
Also, the to
view controller must be added as a subview of the containerView
in the transition context.
此外,to
视图控制器必须添加为containerView
转换上下文中的子视图。
When your animation completes, you must call transitionContext.completeTransition(true)
. If you are doing an interactive transition, you will have to dynamically return a Bool
to completeTransition(didComplete: Bool)
, depending on if the transition is complete at the end of the animation.
当您的动画完成时,您必须调用transitionContext.completeTransition(true)
. 如果您正在执行交互式过渡,则必须动态返回 aBool
到completeTransition(didComplete: Bool)
,具体取决于过渡是否在动画结束时完成。
Finally (optional reading), you might want to see how I did the transition I was working on. This code is a bit more hacky and I wrote it pretty quickly so I wouldn't say it's great animation code but it still shows how to do the animation part.
最后(可选阅读),您可能想看看我是如何完成我正在处理的转换的。这段代码有点笨拙,我写得很快,所以我不会说它是很棒的动画代码,但它仍然展示了如何制作动画部分。
Mine was a really simple transition; I wanted to mimic the same animation that UINavigationController typically does, but instead of the 'next page over the top' animation it does, I wanted to implement a 1:1 animation of the old view controller away at the same time as the new view controller appears. This has the effect of making the two view controllers seem as though they are pinned to each other.
我的是一个非常简单的过渡;我想模仿 UINavigationController 通常所做的相同动画,但不是它所做的“下一页”动画,我想在新视图的同时实现旧视图控制器的 1:1 动画控制器出现。这具有使两个视图控制器看起来好像彼此固定的效果。
For the push operation, that requires first setting the toViewController
's view origin on the x–axis off screen, adding it as the subview of the containerView
, animating it onto screen by setting that origin.x
to zero. At the same time, I animate the fromViewController
's view away by setting its origin.x
off the screen:
对于推送操作,这需要首先在toViewController
屏幕外的 x 轴上设置的视图原点,将其添加为 的子视图,containerView
通过将其设置origin.x
为零来将其动画化到屏幕上。同时,我fromViewController
通过将 的视图设置为origin.x
关闭屏幕来设置它的动画效果:
toViewController.view.frame = containerView.bounds.offsetBy(dx: containerView.frame.size.width, dy: 0.0)
containerView.addSubview(toViewController.view)
UIView.animate(withDuration: transitionDuration(using: transitionContext),
delay: 0,
options: [ UIViewAnimationOptions.curveEaseOut ],
animations: {
toViewController.view.frame = containerView.bounds
fromViewController.view.frame = containerView.bounds.offsetBy(dx: -containerView.frame.size.width, dy: 0)
},
completion: { (finished) in
transitionContext.completeTransition(true)
})
The pop operation is basically the inverse. Add the toViewController
as a subview of the containerView
, and animate away the fromViewController
to the right as you animate in the toViewController
from the left:
弹出操作基本上是相反的。添加toViewController
作为 的子视图containerView
,并fromViewController
在toViewController
从左侧设置动画时向右移动:
containerView.addSubview(toViewController.view)
UIView.animate(withDuration: transitionDuration(using: transitionContext),
delay: 0,
options: [ UIViewAnimationOptions.curveEaseOut ],
animations: {
fromViewController.view.frame = containerView.bounds.offsetBy(dx: containerView.frame.width, dy: 0)
toViewController.view.frame = containerView.bounds
},
completion: { (finished) in
transitionContext.completeTransition(true)
})
Here's a gist with the whole swift file:
这是整个 swift 文件的要点:
https://gist.github.com/alanzeino/603293f9da5cd0b7f6b60dc20bc766be
https://gist.github.com/alanzeino/603293f9da5cd0b7f6b60dc20bc766be
回答by eilas
There are UINavigationControllerDelegate and UIViewControllerAnimatedTransitioning there you can change animation for anything you want.
有 UINavigationControllerDelegate 和 UIViewControllerAnimatedTransitioning 在那里你可以改变任何你想要的动画。
For example this is vertical pop animation for VC:
例如,这是 VC 的垂直流行动画:
@objc class PopAnimator: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
return 0.5
}
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
let containerView = transitionContext.containerView()
let bounds = UIScreen.mainScreen().bounds
containerView!.insertSubview(toViewController.view, belowSubview: fromViewController.view)
toViewController.view.alpha = 0.5
let finalFrameForVC = fromViewController.view.frame
UIView.animateWithDuration(transitionDuration(transitionContext), animations: {
fromViewController.view.frame = CGRectOffset(finalFrameForVC, 0, bounds.height)
toViewController.view.alpha = 1.0
}, completion: {
finished in
transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
})
}
}
}
And then
进而
func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if operation == .Pop {
return PopAnimator()
}
return nil;
}
Useful tutorial https://www.objc.io/issues/5-ios7/view-controller-transitions/
有用的教程 https://www.objc.io/issues/5-ios7/view-controller-transitions/
回答by vp2698
Based on jordanperry
answerupdated for swift 4
基于 为 swift 4 更新的答案jordanperry
For push UIViewController
为推 UIViewController
let yourVC = self.storyboard?.instantiateViewController(withIdentifier: "yourViewController") as! yourViewController
UIView.animate(withDuration: 0.75, animations: {() -> Void in
UIView.setAnimationCurve(.easeInOut)
self.navigationController?.pushViewController(terms, animated: true)
UIView.setAnimationTransition(.flipFromRight, for: (self.navigationController?.view)!, cache: false)
})
For Pop
流行音乐
UIView.animate(withDuration: 0.75, animations: {() -> Void in
UIView.setAnimationCurve(.easeInOut)
UIView.setAnimationTransition(.flipFromLeft, for: (self.navigationController?.view)!, cache: false)
})
navigationController?.popViewController(animated: false)