點選tabbaritem時出現過度動畫
阿新 • • 發佈:2019-02-02
首先建立UITabBarController,單獨寫成一個類或者直接在appdelegate裡面建立都可以
a)遵守協議
<UITabBarControllerDelegate>
b)設定代理
tabbar.delegate = self;
c)實現UITabBarControllerDelegate代理方法,這裡使用了大家熟悉的CATrabsition動畫
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController
{
CATransition* animation = [CATransitionanimation];
[animation setDuration:10.0f];
[animation setType:@"rippleEffect"];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseOut]];
[self.view.layer addAnimation:animation forKey:@"switchView"];
}
//大功告成!點選tabbaritem的時候都會觸發代理方法從而出現動畫,效果圖如上!