對UITabBarController上TabBar按鈕動畫詳細介紹-->>保證你有意外收獲,如有問題歡迎指點。。
廢話就不多說了直接上效果圖,這是我公司項目中加的動畫,自己可以適當的加以修改稱自己想要的
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { NSInteger index = [self.tabBar.items indexOfObject:item]; if (self.indexFlag != index) { [self animationWithIndex:index]; } } // 動畫 - (void)animationWithIndex:(NSInteger) index { NSMutableArray * tabbarbuttonArray = [NSMutableArray array]; for (UIView *tabBarButton in self.tabBar.subviews) { if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) { [tabbarbuttonArray addObject:tabBarButton]; } } CABasicAnimation*pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; pulse.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; pulse.duration = 0.08; pulse.repeatCount= 1; pulse.autoreverses= YES; pulse.fromValue= [NSNumber numberWithFloat:0.7]; pulse.toValue= [NSNumber numberWithFloat:1.3]; [[tabbarbuttonArray[index] layer] addAnimation:pulse forKey:nil]; self.indexFlag = index; }