0

我正在尝试模拟 TweetBot/NetBot 在从帐户操作的 tableView 推送后为 tabBar 设置动画的方式。当视图被完全推入时,taBar 才会从底部动画。我尝试了各种隐藏/显示方法,但在“显示”部分似乎都失败了。

有人对如何做到这一点有建议吗?

4

1 回答 1

0

首先,我假设您没有使用 UITabViewController,因为它不能被推入 UINavigationController 堆栈,所以我认为您使用的是嵌入在 UIViewController 中的独立 UITabBar。这个假设正确吗?

尝试使用此代码(我没有尝试过)。

- (void)viewDidAppear {
    [super viewDidAppear];

    // Calls showTabBar method after SOME_DELAY. You can also call directly [self showTabBar] if you want zero delay.
    [self performSelector:@selector(showTabBar) afterDelay:SOME_DELAY];
}

- (void)showTabBar {
   // Before the animation begins, your UITabBar must be outside the view controller's view frame. 
   CGRect tabBarFrame = CGRectMake(0,
                                   CGRectGetHeight(self.view.bounds), 
                                   CGRectGetWidth(self.view.bounds),
                                   CGRectGetHeight(self.tabBar.frame);
   self.tabBar.frame = tabBarFrame;

   // Let's start with the animation, setting a new frame for tab bar inside an animation block
   [UIView animateWithDuration:ANIMATION_DURATION animations:^{
       // Change origin Y. It assumes that the height of self.tabBar is right, otherwise put the height you want instead of CGRectGetHeight(self.tabBar.frame).
       tabBarFrame.origin.y = CGRectGetHeight(self.view.bounds) - CGRectGetHeight(self.tabBar.frame); 

       self.tabBar.frame = tabBarFrame;
   }];
}
于 2013-04-07T13:36:13.940 回答