开发者

Full screen in one tab of UITabBarController

Currently, five UIViewControllers are switched via a UITabBarController. How can I hide the TabBar and provide a full-screen for one of the UIViewControllers?

For example:

  • The middle tab is clicked
  • T开发者_JAVA百科he UITabBarController TabBar is hidden
  • The UIViewController takes full screen (hides status bar also)
  • When one button in the middle is clicked, switch to the first tab (status bar resumes, UITabBarController TabBar resumes)


You can put the view controller in a navigation controller and set the view controller's hidesBottomBarWhenPushed property to YES. Hiding the status bar can be done using statusBarHidden property of the shared application object.


First, right-click the tab bar in Interface Builder and drag "delegate" to "File's Owner".

Then, add the following method to the tab bar controller:

– (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    [UIView animateWithDuration:0.5 animations:^(void) {
        tabBar.transform = CGAffineTransformMakeTranslation(0, 480);
    }];
}

and when a button is clicked, add the tabbar as an outlet to the tab bar controller, and then do the following when the button is pressed:

[UIView animateWithDuration:0.5 animations:^(void) {
        tabBarController.tabBar.transform = CGAffineTransformMakeTranslation(0, 431);
}];

Done!


To hide the tab bar, you can use:

    tabBarController.tabBar.hidden = YES;

you can call this from the viewWillAppear method of the controller associated to the middle tab bar view, or in your tab bar controller delegate's –tabBarController:shouldSelectViewController:

You will have to do the opposite in viewWillAppear of all other view controllers, or when clicking the "resume" button;

In order to hide the status bar:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

at the same places as above.


I solved the issue by doing the following.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

segue.destinationViewController.hidesBottomBarWhenPushed = YES

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜