Xcode: getting rid of black bar when hiding navbar

Scenario

I have an application that allows users to scroll to the top of a UITableView to view messages. When they scroll up, the navigation bar will hide. I am using the code from the following SO post ...

Mimic iOS 7 Facebook Hides / Shows Expanding / Shrinking Navigation Bar

Problem

When I tried the first answer there, it worked the first time I used it, great. After I got it where it worked, I tried to pull my tabulator out. When I fidgeted with my code, I must have faked something. Because now when I run the same code, I get this black bar that won't go away.

Unallocated (regular)

enter image description here

Scrolled Up (leaves an ugly black streak)

enter image description here

What I have also tried

GTScrollNavigationBar and TLYShyNavBar

and they both leave a black streak as well ...

Question

Does anyone know how to fix this?

+3


source to share


2 answers


I think your problem here is because your navigation bar is not transparent. In your view controller, make sure the Under Opaque Bars property is checked and everything should be fine.

enter image description here



Another way to do this is to set extendedLayoutIncludesOpaqueBars

to YES

(not the default) on your view controller.

+17


source


I would recommend just doing it in code for full control and additional functionality later.

Just set the background color to the appropriate table view. In your case, it would be something like this:



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

      

+1


source







All Articles