首先创建UITabBarController,单独写成一个类或者直接在appdelegate里面创建都可以
a)遵守协议
<UITabBarControllerDelegate>
b)设置代理
tabbar.delegate = self;
c)实现UITabBarControllerDelegate代理方法,这里使用了大家熟悉的CATrabsition动画
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
CATransition* animation = [CATransition animation];
[animation setDuration:10.0f];
[animation setType:@"rippleEffect"];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[self.view.layer addAnimation:animation forKey:@"switchView"];
}
//大功告成!点击tabbaritem的时候都会触发代理方法从而出现动画,效果图如上!