8

I am getting a really strange animation behaviour when pushing another view controller that has the bottom bar hidden with hidesBottomBarWhenPushed. The first thread I found was that: Strange animation on iOS 7 when using hidesBottomBarWhenPushed in app built targeting <= iOS 6 but as my application is only build and run on iOS7 it is not the case for my problem.

Please see the following video that shows the problem (look in the top right corner):

https://dl.dropboxusercontent.com/u/66066789/ios7.mov

This strange animation shadow only occurs when hidesBottomBarWhenPushed is true. How can I fix that?

Community
  • 1
  • 1
priojewo
  • 937
  • 2
  • 11
  • 22
  • What is strange in the animation? Do you mean the flicker at the right? – Léo Natan Mar 19 '14 at 19:24
  • Yes, the black shadow flickering in the upper right corner. – priojewo Mar 19 '14 at 19:44
  • 1
    This happens because extended edges are off on the pushed view controller. That's where they happened in my app. – Léo Natan Mar 19 '14 at 19:56
  • 1
    Extended edges is "Under Top Bars, Under Bottom Bars". This is by default. Tried to turn it off, still the same problem.. – priojewo Mar 19 '14 at 20:18
  • 3
    The video is not accessible through the link now. Would you mind putting it back? This post is very valuable to me because I also encountered the same issue and this post seems to be the only place where I can find people talking about it. –  Jan 23 '15 at 12:33

6 Answers6

20

Solved my problem:

self.tabBarController.tabBar.hidden=YES;

In the second view controller is the way to go.

priojewo
  • 937
  • 2
  • 11
  • 22
  • Try rotating the view controller, [see what happens](http://stackoverflow.com/questions/20578994/on-ios-7-pushing-a-controller-with-a-toolbar-leaves-a-gap-of-unusable-space-if/20622663#20622663) – Léo Natan Mar 19 '14 at 20:24
  • What do you mean by rotating? This really seems to work fine. – priojewo Mar 19 '14 at 20:31
13

Leo Natan is correct. The reason for this blur effect is because the entire Tab Bar Controller is being animated underneath the navigation controller, and behind that view is a black UIWindow by default. I changed the UIWindow background color to white and that fixed the issue.

hidesBottomBarWhenPushed seems to work great with UITabBars (iOS 7/8).

chourobin
  • 4,004
  • 4
  • 35
  • 48
  • 4
    This is the working answer for me, after searching for hours. –  Jan 23 '15 at 12:48
  • I never thought about changing UIWindow's color... brilliant! – Islam Dec 02 '15 at 18:25
  • I must leave a comment to say after 6 years later this bug still exists on iOS 13 and this workaround may save hours for me. BTW, to support dark mode, `window.backgroundColor` should be `UIColor.systemBackground`. – ribilynn Dec 26 '19 at 13:41
2

Turn off the Translucent property of Navigation Bar in Storyboard.

STAR_ZERO
  • 1,400
  • 11
  • 21
2

In My Case, I had TabBarViewController with UINavigationController in each tabs & faced similar issue. I used,

nextScreen.hidesBottomBarWhenPushed = true
pushViewToCentralNavigationController(nextScreen)

It works fine when nextScreen is UITableViewController subclass & applied auto layout. But, It does not work fine when nextScreen is UIViewController. I found it depends on nextScreen auto layout constraints.

So I just updated my currentScreen with this code -

override func viewWillDisappear(animated: Bool) {

        super.viewWillDisappear(animated)

        self.tabBarController?.tabBar.hidden = true

    }

For more details - https://stackoverflow.com/a/39145355/2564720

Community
  • 1
  • 1
Nico
  • 1,788
  • 2
  • 23
  • 41
1

An elegant way of doing this, while keeping transparency, is to add this to the root UIViewController:

- (void)viewWillAppear:(BOOL)animated {
    [UIView animateWithDuration:0.35f animations:^{
        self.tabBarController.tabBar.alpha = 1.0f;
    }];
}

- (void)viewWillDisappear:(BOOL)animated {
    [UIView animateWithDuration:0.35f animations:^{
        self.tabBarController.tabBar.alpha = 0.0f;
    }];
}

This way you'll get a nice fade-in/fade-out animation of the tab bar.

nikolovski
  • 4,049
  • 1
  • 31
  • 37
  • Awesome answer since you don't have to maintain the tabbar visibility for other view controllers being presented or pushed. – Quxflux Oct 31 '15 at 18:24
0

What if in the second view controller in viewWillAppear you put

[self.navigationController setToolbarHidden:YES animated:NO];
Ilea Cristian
  • 5,741
  • 1
  • 23
  • 37
  • Because it's a tab bar, not a toolbar. – Léo Natan Mar 19 '14 at 20:19
  • 3
    Then `self.tabBarController.tabBar.hidden=YES;` ? – Ilea Cristian Mar 19 '14 at 20:21
  • @IleaCristian This will create another problem, where there will be an empty space on the bottom. – Léo Natan Mar 19 '14 at 20:24
  • I guess you are referring to the fact that the scrollview (tableview) insets are set in such a way that content shows well, but it also has the chance to get beneath the translucent view (nav bar/tab bar etc.). Well, in iOS7 there is a new viewcontroller property to stop that from happening. Just set self.automaticallyAdjustsScrollViewInsets to NO. But then the tableview would go under the nav bar as well. The solution is to set a custom contentInset for the table view using some new iOS7 properties: self.topLayoutGuide.length and self.bottomLayoutGuide.length. The length is the bar height. – Ilea Cristian Mar 19 '14 at 20:30
  • The problem is, `self.bottomLayoutGuide.length` returns incorrectly in some cases, when the bar is hidden by `tabBar.hidden = YES;`. – Léo Natan Mar 19 '14 at 20:34
  • Hmmm, never tested. Nice catch @LeoNatan. – Ilea Cristian Mar 19 '14 at 20:35
  • @priojewo But why are you trying to achieve this weird effect? It feels hack-ish. – Ilea Cristian Mar 19 '14 at 20:36