0

I ran into a problem with a translucent tab bar I use. I've got a UITabBarController embedding a UINavigationController having a simple UIViewController as its root. The TabBar is as I said translucent.

When I try to push a view controller on the navigation controllers stack the transition is chopped under the tab bar.

And after the transition completes the background color of the pushed view controller is set under the translucent tab bar (the red color is just for this example)

Yes, I could set the backgroundColor of the tabControllers view to f.i. red and override the black but it still would be chopped.

I've found a lot of issues of that kind but usually the solution was "instantiate from storyboard" but I do not use storyboards and haven't found any solution that worked

There's nothing special about the code its just a simple push on a navigation controller.

let diningDetailController = DiningDetailController()

navigationController?.pushViewController(diningDetailController, animated: true)

The DiningDetailController:

import UIKit

class DiningDetailController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .red
    }
}

You can see in the attached gif what it actually looks like and I think you can image how it should behave. The red view controller should be coming in smoothly and behind the translucent bar

without translucency it works perfectly of course because you cannot see what's behind that damn bar but the bar is supposed to be translucent.

I hope any of you know a solution for this issue. Thanks in advance

Dennis
  • 200
  • 15
  • I just tried to reproduce this issue and [everything works fine here](https://imgur.com/a/gJdjm5X). Can you try setting the DiningDetailController background color on its `ViewDidLoad` method (`self.view.backgroundColor = .blue`)? If the problem persists, tell us your xCode version, iOS version and DiningDetailController code for us to try reproducing the problem. – alxlives Sep 06 '19 at 21:56
  • I set the background color inside viewDidLoad just in red in my case. Still happening. The Xcode Version is 10.3, iOS 12.4.1. The DiningDetailController is just setting the background color to red, but I can update the question with the full code anyway. – Dennis Sep 06 '19 at 22:05

2 Answers2

1

Ok, I found the issue. Apparently it was some kind of a cached build thing I don't really know but In the gif you can see, that the table views bottom constraint is snapped to the bottom constraint of the view.

For the sake of trying I used the views bottom safe area layout guide so the bottom anchor of the table view snaps to the top anchor of the tab bar. I built it and there were obviously no issues because the view wasn't behind the tab bar anymore.

When I changed back the constraint to use self.view.bottomAnchor again it worked for a reason I don't know. I triple checked my git status there isn't a single character changed in the codebase.

Is it possible that this was caused by some cached data?

Dennis
  • 200
  • 15
  • 1
    Probably. The new build system has some cache problems. You can use the Legacy Build System as a solution: https://stackoverflow.com/a/54720211/3241041 – alxlives Sep 06 '19 at 22:25
0

The 'black background' is your window's background color, so you can try to set your UIApplication.sharedApplication.delegate.window.backgroundColor = Red.

MoLice
  • 301
  • 2
  • 7