【问题标题】:Tab bar item transition标签栏项目过渡
【发布时间】:2017-08-28 22:07:59
【问题描述】:

我的代码中有一个标签栏控制器,我想在标签栏项目之间进行动画转换。我找到了一种用控制器来做到这一点的方法,但不是用这些项目。我知道我必须使用 UIView.animate,但我不知道如何。有什么想法吗?

【问题讨论】:

  • 你想看什么动画?所有标签栏项目都是可见的,因此项目之间不需要任何淡入淡出。
  • Tab 项之间的动画过渡。我能做到吗?
  • 你的问题不清楚。当您单击不同的选项卡时,您希望与标准 UITabBar 有什么不同?
  • 我在标签栏项目的顶部有一个图像指示器,当更改项目时,想要在此图像中显示动画。
  • 对不起我的英语。我来自巴西

标签: ios swift uitabbarcontroller uitabbar uitabbaritem


【解决方案1】:

我有一个带有一些tabBar项目的tabBarController,当我点击这些项目时,它的比例会变大然后回到默认大小,它看起来就像一个动画。 使用Objective-C,您可以按如下方式使用:

//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;

        }];
    }];

}

【讨论】:

  • 我想我只会为控制器制作动画,但谢谢!
  • 你只是想在tabBarController的不同viewController之间做一个动画?
  • 不,我想在标签栏索引中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-08
  • 2018-11-11
  • 2022-01-05
  • 1970-01-01
相关资源
最近更新 更多