TabBarController控制器切换的时候添加动画

iOS中TabBarController是很强大的控制器,使用起来也非常的方便,但是它点击tabbaritem切换视图时却不像navigation一样有种划入划出的效果,那么怎么在TabBarController控制器切换的时候添加动画呢? 
在TabBarControllerDelegate中已经定义好了方法,我们可以在自己的TabBarController中实现这个协议中的方法,就可以在切换视图的时候加入动画效果。 
 

1.创建一个类TabBar_Transformer继承NSObject,实现UITabBarController的代理

- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC  

再实现

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext 方法,重写动画逻辑

2.创建一个类SJTabBarController继承UITabBarController,然后把SJTabBarController的代理设置成TabBar_Transformer
 

以上两个文件下载地址:https://github.com/tangmengbo/TabBarController--.git

猜你喜欢

转载自blog.csdn.net/u013857988/article/details/87627519