Before you mark it as duplicate please note, that I did read this and this seems to not apply to UITabBar
Both UIViewController
and UITabBar
are created programmatically. Constraints are set like:
public override func viewDidLoad() {
super.viewDidLoad()
self.view.bringSubview(toFront: self.tabBar)
}
And self.tabBar
:
lazy var tabBar: UITabBar = {
let tab = UITabBar()
self.view.addSubview(tab)
tab.translatesAutoresizingMaskIntoConstraints = false
tab.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true
tab.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
tab.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true //This line will change in second part of this post.
return tab
}()
And this show UITabBar
like this:
And it's too small cause it's not taking safe areas into consideration. So I did change line:
tab.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
to:
tab.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor).isActive = true
And it's then shown like this:
So it's also not shown as expected. The goal here is sth like this:
How to make constraints to show UITabBar
like this?