Reputation: 288
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
Upvotes: 0
Views: 1668
Reputation: 311
The 'black background' is your window's background color, so you can try to set your UIApplication.sharedApplication.delegate.window.backgroundColor = Red
.
Upvotes: 0
Reputation: 288
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?
Upvotes: 1