tabBarItem 点击的时候 能否设置一个好看的动画 下面的代码可以实现
- (void)tabBarController:(UITabBarController *)theTabBarController didSelectViewController:(UIViewController *)viewController
{
[viewController.tabBarItemsetBadgeValue:@"3"];
NSMutableArray *arrayBt = [NSMutableArrayarray];
for (id tabBt in [theTabBarController.tabBar subviews])
{
NSLog(@"~~~~~~~%@",tabBt);
if ([tabBtisKindOfClass:NSClassFromString(@"UITabBarButton")])
{
[arrayBt addObject:tabBt];
}
}
UIView *view = [arrayBtobjectAtIndex:tabBarController.selectedIndex];
int i=0;
for (id tmp in [view subviews])
{
NSLog(@"--------%@",tmp);
i++;
if ([tmpisKindOfClass: NSClassFromString(@"UITabBarSelectionIndicatorView")])
{
//
break;
}
}
CATransition *transition = [CATransitionanimation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromBottom;
[[[[view subviews]objectAtIndex:i]layer] addAnimation:transition forKey:nil];
}