remy boys
remy boys

Reputation: 2958

tabBar & navigation bar became dark after updating to Xcode 8

After updating my Xcode to Xcode 8, i'm facing this strange issue. I have a tab bar and 3 tabs in it when tab1 is selected tab bar and navigation looks like this :

tab bar's background color is white but its showing a dark color instead

enter image description here

and when I select any other tab the problems gets fix

in the below image I've selected tab2

enter image description here

I do not know why its happening but in tab1's ViewController I have a tableView and in tab2 I have a ViewController

anybody knows why is this happening ??

debug hierarchy :

when TAB1 is selected enter image description here


when any other tab is selected enter image description here

i dont know why but tabbar's UIVisualEffectBackdropView's background color is black on tab1 and its transparent in other tabs

Upvotes: 5

Views: 5469

Answers (5)

nurtugan
nurtugan

Reputation: 79

I have just changed view controller's background color property from .default to .systemBackgroundColor

Upvotes: 0

Zaid Pathan
Zaid Pathan

Reputation: 16820

This helped me while performing segue:

Remove hidesBottomBarWhenPushed or disable it.

destination.hidesBottomBarWhenPushed = false

Upvotes: 0

Jamie Birch
Jamie Birch

Reputation: 6112

For anyone else suffering this problem for different reasons to OP:

This exact problem occurred for me when I added the line edgesForExtendedLayout = [] into my UIViewController's loadView() method to stop my view going under the navigation bar. Thus, removing that line and instead achieving the same aim using navigationController?.navigationBar.isTranslucent = false fixed it for me (although John Doe's solution may have been viable too). I guess that when there is no view laid under your toolbar, the UIVisualEffectBackdropView becomes opaque and it just happens to be black. This appears to produce a dark toolbar if your toolbar is transparent.

Upvotes: 14

John Doe
John Doe

Reputation: 2341

You can solve this locally (for e.g. if you have a CustomTabBarController), and globally. I am providing both solutions here, just for you:

1. Locally:

    class YourCustomTabBarVC: UITabBarController {

    //MARK:- Initializers
    required init?(coder aDecoder:NSCoder) {
        super.init(coder: aDecoder)
        __customInit()
    }  

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        __customInit()
    }

    fileprivate func __customInit() {
        addObservers()

       //Customize TabBar appearance:
        tabBar.backgroundColor = UIColor.white
    }
    }

2. Globally: in your AppDelegate.swift:

 func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions
    launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
   /* Your other code*/   
   UITabBar.appearance().backgroundColor = UIColor.white // {UR_DESIRED_COLOR}

}

I would suggest you to use the global method. Add that one line, and voila! You will be scrambling to write a personal thank you message right underneath here!

Upvotes: 4

remy boys
remy boys

Reputation: 2958

turn out adding shadow on my toolBar caused the issue :

the below code was giving me proper shadow in Xcode7 (swift 2) but after updating to Xcode 8 (swift 3) it changed the color of my other bars (tab bar + navigation bar) :

toolbar.layer.masksToBounds = false
toolbar.layer.shadowOffset = CGSize(width: -1, height: 1)
toolbar.layer.shadowRadius = 1
toolbar.layer.shadowOpacity = 0.5

Upvotes: 2

Related Questions