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];
}
本文介绍了一种在iOS应用中为UITabBar设置自定义动画的方法。通过在控制器被选中时修改对应的UITabBarButton视图,实现了平滑过渡的动画效果。此方案使用了Core Animation来定制选择指示器的动画。
289

被折叠的 条评论
为什么被折叠?



