Xcode: Getting rid of black bar when hiding navigation bar

匿名 (未验证) 提交于 2019-12-03 07:36:14

问题:

Scenario

I have an app that allows users to scroll up on a UITableView to view posts. When they scroll up the navigation bar will hide. I use the code from the following SO post...

Imitate iOS 7 Facebook hide/show expanding/contracting Navigation Bar

Problem

When I tried the first answer on there it worked the first time I used it, perfectly. After I got it to where it was working I tried to get my Tab Bar to drop down as well. When I fidgeted around with my code I must have fudged something up. Because now when I run the same code, I get this black bar that won't go away.

Unscrolled (normal)

Scrolled Up (leaves ugly black bar)

What I've also tried

GTScrollNavigationBar and TLYShyNavBar

and they both leave the black bar also...

Question

Does anyone know how to fix this?

回答1:

I think your issue here has to do with your navigation bar not being transparent. In your view controller, make sure the property Under Opaque Bars is checked and it should be fine.

Another way to doing that is to set extendedLayoutIncludesOpaqueBars to YES (not the default) on your view controller.



回答2:

I would recommend to just do it in code for full control and additional possibilities later on.

Simply set the background color of the concerned tableview. In your case that would be something like this:

self.navigationController.view.backgroundColor = [UIColor whiteColor]; 


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