要實(shí)現(xiàn)單擊item轉(zhuǎn)場動畫坑质,只需實(shí)現(xiàn)UITabBarDelegate下面的這個方法-?tabBar: didSelectItem:急鳄,先看效果:
該代理方法加入位置士嚎,為自定義的UITabBarController視圖控制器中,如:
@interface BuyerTabbarCtrl : UITabBarController<UITabBarControllerDelegate>
- (void)viewDidLoad
{
? ? ?[super viewDidLoad];
? ? ?self.delegate = self;
}
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
? ? ?CATransition *animation = [CATransition animation]; //創(chuàng)建CATransition對象
? ? ?animation.duration = 0.77f;? //設(shè)置運(yùn)動時間
? ? ? animation.type = @"rippleEffect"; //設(shè)置運(yùn)動type
? ? ? ?//? ? animation.type = kCATransitionPush;
? ? ? ?animation.subtype = kCATransitionFromLeft; //設(shè)置子類
? ? ? ?animation.timingFunction = UIViewAnimationOptionCurveEaseInOut; //設(shè)置運(yùn)動速度
? ? ? [self.view.layer addAnimation:animation forKey:@"animation"];
}