Search code examples
iosipaduitabbarcontrolleruisplitviewcontroller

UISplitViewController inside UITabbarController: master controller doesn't go under UITabbar


I read through few existing questions and tried setting "Under Opaque Bar" to no avail. enter image description here

See how the navigation bar and tabbar under master view is darker? This is plain Xcode7 new project with split view. The only thing added - UITabbarController.

What am I missing? enter image description here

UPDATE Here is link to compressed project: https://dl.dropboxusercontent.com/u/6402890/dds1.zip


Solution

  • This is quite an odd issue. Testing with your project, it seems to only affect iPad Air and iPad Air2 and iPhone 6+, not iPad Retina or iPad 2.

    The issue relates to the setting of the UINavigationBar barTintColor and the UITabBar barTintColor.

    You can fix your issue by doing the following:

    1) For each UINavigationController, set the UINavigationBar barTintColor to white or deselect the translucent switch. You can do this in IB by selecting the navigation controller and then selecting the contained nav bar in the view hierarchy.

    This deals with the top shadow.

    2) For the UITabBarController, set the UITabBar barTintColor to white or deselect the translucent switch. You can do this in IB by selecting the tab bar controller and then selecting the contained tab bar in the view hierarchy.

    This deals with the bottom shadow.


    When I set both to white it works. When I set both to be not translucent it works. Setting the color you want seems the best idea rather than changing the translucent setting.

    As to why? Using the 3D viewer it looks like there is a long navigation bar style UIView which is 64 points high and grey which runs along the whole width of the split view controller. For whatever reason, on iPad Air and iPhone 6s, this is showing through. I guess it relates to the hardware acceleration or some other device specific feature in the newer devices.

    Update:

    Had another look, and the cause of the shadow is the background color of the UISplitViewController. You can not set this in IB it seems, but it looks like it has a grey color by default which is what you see showing through.

    To fix this you need to create a class for the UISplitViewController and set the main views background color. Something like:

    class MySplitViewController: UISplitViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // Set the background color to white instead of default grey.
            self.view.backgroundColor=UIColor.whiteColor()
        }
    }
    

    So this seems the simplest solution.