用于UITabBarController动画的Transition Delegate

erd*_*ser 5 transitions uiviewanimationtransition ios swift xcode6

我已经UIViewControllerAnimationTransition创建了一个自定义类,并且需要UITabBarController在切换选项卡时使其成为动画.

但是,tabBarController它不使用常规标签栏.我有一个类似于它的自定义实现,当按下按钮时,它会调用以下代码:

tabBarController.selectedIndex = index
Run Code Online (Sandbox Code Playgroud)

目前我有tabBarController(子类)作为自己的委托transitionDelegate.但是,委托方法animationControllerForPresentedController实际上从未被调用过.

标签栏控制器是否可以成为自己的委托?如果是这样,为什么转换代码永远不会被调用?

erd*_*ser 14

animationControllerForPresentedController 标签栏控制器是错误的方法.

在UITabBarController子类中,采用UITabBarControllerDelegate协议并将其设置为自己的协议delegate.然后,用于tabBarController: animationControllerForTransitionFromViewController: toViewController:返回自定义UIViewControllerAnimatedTransitioning对象.

为了获得更好的可视化,看看VCTransitionsLibrary在TabBarDemo文件夹中.