I have a tab bar controller in my code and I want to make the transition with animation between the tab bar items. I found a way to do this with the controllers, but not with the items. I know I have to use UIView.animate, but I don't know how. Any ideas?
Asked
Active
Viewed 1,012 times
0

rmaddy
- 314,917
- 42
- 532
- 579

Rodrigo D'Angelo Machado
- 49
- 1
- 1
- 7
-
1What animation do you wish to see? All of the tab bar items are visible so there is no need for any kind of fade between the items. – rmaddy Aug 28 '17 at 22:14
-
A animate transitivos beetwen the Tab items. I can do this? – Rodrigo D'Angelo Machado Aug 28 '17 at 22:20
-
Your question is not clear. What exactly do you want to do differently from a standard UITabBar when you click on a different tab? – rmaddy Aug 28 '17 at 22:22
-
I have an image indicator in the top of the Tab bar items, and when a change the item, a wanna an animation in this image. – Rodrigo D'Angelo Machado Aug 28 '17 at 22:25
-
Sorry for my English. I'm from Brazil – Rodrigo D'Angelo Machado Aug 28 '17 at 22:25
-
Your English is fine. But you may be interested in [Stack Overflow em Português](https://pt.stackoverflow.com/). – rmaddy Aug 28 '17 at 22:41
1 Answers
0
I have a tabBarController with some tabBar items,when I click the item,it‘s scale will larger and then back to default size,it just looks as an animation.
With Objective-C
you can use as follows :
//didSelectItem
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
NSInteger index = [self.tabBar.items indexOfObject:item];
[self animationWithIndex:index];
}
//animation
- (void)animationWithIndex:(NSInteger) index {
NSMutableArray *tabBarBtnArr = [NSMutableArray array];
for (UIView *tabBarBtn in self.tabBar.subviews) {
if ([tabBarBtn isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[tabBarBtnArr addObject:tabBarBtn];
}
}
UIButton *btn=tabBarBtnArr[index];
[UIView animateWithDuration:0.2 animations:^{
btn.transform=CGAffineTransformMakeScale(1.2, 1.2);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.2 animations:^{
btn.transform=CGAffineTransformIdentity;
}];
}];
}
-
I think I will animate the controllers only, but thanks! – Rodrigo D'Angelo Machado Aug 29 '17 at 12:56
-
You just want to make a animation between the different viewControllers of the tabBarController ? – Aug 29 '17 at 12:59
-