1. 程式人生 > >點選tabbaritem時出現過度動畫

點選tabbaritem時出現過度動畫

 首先建立UITabBarController,單獨寫成一個類或者直接在appdelegate裡面建立都可以

  a)遵守協議

<UITabBarControllerDelegate>

b)設定代理

tabbar.delegate = self;

c)實現UITabBarControllerDelegate代理方法,這裡使用了大家熟悉的CATrabsition動畫

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController

*)viewController

    {

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的時候都會觸發代理方法從而出現動畫,效果圖如上!