5

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

remy boys
  • 2,675
  • 5
  • 28
  • 57
  • This looks like you have another view or mask on top of it. Not only background is different, the tab image colour appears to be different as well. Or check some alpha-s. If you have set some alpha, the previous iOS SDK could have not understood it before. – pedrouan Sep 19 '16 at 11:06
  • Please see the answer below. Hope this is already fixed for you. – John Doe Dec 13 '16 at 21:37

5 Answers5

13

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.

Jamie Birch
  • 4,408
  • 1
  • 32
  • 50
3

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!

John Doe
  • 1,863
  • 1
  • 17
  • 12
2

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
remy boys
  • 2,675
  • 5
  • 28
  • 57
0

This helped me while performing segue:

Remove hidesBottomBarWhenPushed or disable it.

destination.hidesBottomBarWhenPushed = false
Mohammad Zaid Pathan
  • 14,352
  • 6
  • 84
  • 112
0

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

nurtugan
  • 94
  • 2
  • 2