1. 程式人生 > >UITabBarController 頁面切換動畫

UITabBarController 頁面切換動畫

但是這裡介面切換的實現全部由UITabBarController,也就是系統自動幫你來實現了,要在哪裡新增動畫程式碼呢?

很簡單,寫一個類繼承自UITabBarController,然後實現下面這個委託方法就行了:

CATransition* animation = [CATransition animation];
        [animation setDuration:0.5f];
        [animation setType:kCATransitionFade];
        [animation setSubtype:kCATransitionFromRight];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
        [[self.view layer]addAnimation:animation forKey:@"switchView"];