iOS7 strange animation when using hidesBottomBarWhenPushed

♀尐吖头ヾ 提交于 2019-11-27 01:59:12

问题


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?


回答1:


Solved my problem:

self.tabBarController.tabBar.hidden=YES;

In the second view controller is the way to go.




回答2:


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).




回答3:


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




回答4:


Turn off the Translucent property of Navigation Bar in Storyboard.




回答5:


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.




回答6:


What if in the second view controller in viewWillAppear you put

[self.navigationController setToolbarHidden:YES animated:NO];


来源:https://stackoverflow.com/questions/22516046/ios7-strange-animation-when-using-hidesbottombarwhenpushed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!