How to Hide Uitabbar

How to hide uitabbarcontroller

I am pasting this from my working code... you can call these methods to hide and show the tabbarcontroller.... just pass tabbarcontroller instance to these functions..

// Method call
[self hideTabBar:self.tabBarController];

// Method implementations
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];

for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}

[UIView commitAnimations];
}

- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(@"%@", view);

if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];

}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}

[UIView commitAnimations];
}

Hide tab bar in IOS swift app

You can simply use this in your ViewDidLoad() method.

self.tabBarController?.tabBar.hidden = true

For Swift 3.0, 4.0, 5.0:

self.tabBarController?.tabBar.isHidden = true

Or you can change z position of tab bar this way:

self.tabBarController?.tabBar.layer.zPosition = -1

and if you want to show it again then:

self.tabBarController?.tabBar.layer.zPosition = 0

Hiding the tabbar and removing the space

If you're still seeing a black stripe under your hidden tab bar, have you tried to select Extend Edges Under Opaque Bars here?

enter image description here

Make also sure that Under Bottom Bars is still selected. Hope it helps!

How to hide UITabBar?

You have to use set the hidesBottomBarWhenPushed property to YES on the controller that you are pushing and NOT to the UITabBarController.

otherController.hidesBottomBarWhenPushed = YES;
[navigationController pushViewController: otherController animated: TRUE];

Or you can set the property when you first initialize the controller you want to push.

Swift UITabBarController hide with animation

You could change the tab bar's frame inside an animation, so something like:

func hideTabBar() {
var frame = self.tabBarController?.tabBar.frame
frame?.origin.y = self.view.frame.size.height + (frame?.size.height)!
UIView.animate(withDuration: 0.5, animations: {
self.tabBarController?.tabBar.frame = frame!
})
}

func showTabBar() {
var frame = self.tabBarController?.tabBar.frame
frame?.origin.y = self.view.frame.size.height - (frame?.size.height)!
UIView.animate(withDuration: 0.5, animations: {
self.tabBarController?.tabBar.frame = frame!
})
}

Which sets the tab bar just below the visible screen, so that it slides up/down from the bottom.

How to hide tab bar with animation in iOS?

I try to keep view animations available to me using the following formula:

// pass a param to describe the state change, an animated flag and a completion block matching UIView animations completion 
- (void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated completion:(void (^)(BOOL))completion {

// bail if the current state matches the desired state
if ([self tabBarIsVisible] == visible) return (completion)? completion(YES) : nil;

// get a frame calculation ready
CGRect frame = self.tabBarController.tabBar.frame;
CGFloat height = frame.size.height;
CGFloat offsetY = (visible)? -height : height;

// zero duration means no animation
CGFloat duration = (animated)? 0.3 : 0.0;

[UIView animateWithDuration:duration animations:^{
self.tabBarController.tabBar.frame = CGRectOffset(frame, 0, offsetY);
} completion:completion];
}

//Getter to know the current state
- (BOOL)tabBarIsVisible {
return self.tabBarController.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame);
}

//An illustration of a call to toggle current state
- (IBAction)pressedButton:(id)sender {
[self setTabBarVisible:![self tabBarIsVisible] animated:YES completion:^(BOOL finished) {
NSLog(@"finished");
}];
}

Disable/hide uitabbaritem on an uitabbar

If you're modifying the tabbar items from the UITabbarController, you can't use setItems:animated:. From the docs:

In iOS 3.0 and later, you should not attempt to use the methods and properties of this class to modify the tab bar when it is associated with a tab bar controller object. Modifying the tab bar in this way results in the throwing of an exception. Instead, any modifications to the tab bar or its items must occur through the tab bar controller interface.

Instead, swap out the viewControllers property of your UITabbarController, removing the UIViewController that corresponds to the tabbar item you want removed. For example, if you want to remove the 2nd tabbar item:

NSMutableArray *newViewControllers = [NSMutableArray arrayWithArray:self.viewControllers];
[newViewControllers removeObjectAtIndex:1];
[self setViewControllers:newViewControllers];

How to Hide Tab Bar Controller?

Try this code:

[self.tabBarController.tabBar setHidden:YES];

where tabbarcontroller is needed to be defined...

EDIT

AppDelegateFileName *appDelegate = (AppDelegateFileName *) [[UIApplication sharedApplication] delegate];
[appDelegate.tabbarController.tabBar setHidden:YES];

before doing this make sure that you create a @property declaration of tabbarController in appDelegate .h file.

Hide an item in the tabBar?

Used similar code to fix the problem.

NSMutableArray *newTabs = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[newTabs removeObjectAtIndex: 3];
[newTabs removeObjectAtIndex: 2];
[self.tabBarController setViewControllers:newTabs];

hide / show tab bar when push / back. swift

As it's name suggest, hiddenBottomBarWhenPushed only hide bottom bar if needed, it will not unhide bottomBar.
You can do this to get it works:

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.tabBarController?.tabBar.hidden = true/false
}

or simply put self.tabBarController?.tabBar.hidden = true/false in prepareForSegue

But I would not recommend you to do so, as it would be weird if bottomBar suddenly popped out, user will thought they suddenly back to rootViewController while they are not.

Users should always know where they are in your app and how to get to their next destination.



Related Topics



Leave a reply



Submit