Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 multitasking switcher: Navbar appears black

The preview window/multitasking switcher shows a weird behaviour in iOS 7. Here is how it appears when I set this property for both apps.

self.navigationController.navigationBar.translucent = NO;

translucent = no Now for the white app I commented the line.

Now when I run it again and go directly to the switcher, this is what I get: enter image description here

If I run the app and then go to the home screen or any other app and then go to the switcher, this is what I get: enter image description here

Is there any way to correct this problem while having translucent navbar?

Thanks.

like image 805
Bilbo Baggins Avatar asked Oct 22 '13 01:10

Bilbo Baggins


2 Answers

I ran into this as well. Since you don't have any content under the translucent navigation bar (and/or tab bar or tool bar), it can sometimes appear black in the app switcher. I was using a collection view that was constrained to the top and bottom layout guides and so there was nothing behind the tab bar and navigation bar. When the app is in the foreground it looks correct because there must be some default background color applied by Apple (maybe on the UIWindow) so you don't see through to the springboard. This background color seems to be gone (or black) when in the app switcher causing it to look like that.

The problem goes away on view controllers that are set to extend under top and/or bottom bars:

self.edgesForExtendedLayout = UIRectEdgeTop | UIRectEdgeBottom;

or in Interface Builder:

enter image description here

If that doesn't fit you needs or you still have other view controllers that don't extend under top and bottom bars you will still get the black bars in the app switcher. The way I solved it was to set the UIWindow background color in my appDelegate.

self.window.backgroundColor = [UIColor whiteColor];

like image 101
Wes Avatar answered Oct 20 '22 07:10

Wes


Instead of doing it in code, you can also do it via Storyboard.

In the navigation bar of your root navigation bar, make sure you turn off its translucency.

enter image description here

I reckon it's a simpler solution.

like image 42
percivalwcy Avatar answered Oct 20 '22 07:10

percivalwcy