title: UITabBar with safe area inside programmatically created UIViewController
body: <p><em>Before you mark it as duplicate please note, that I did read <a href="https://stackoverflow.com/questions/46317061/use-safe-area-layout-programmatically">this</a> and this seems to not apply to <code>UITabBar</code></em></p>
  
  <p>Both <code>UIViewController</code> and <code>UITabBar</code> are created programmatically. Constraints are set like:</p>
  
  <pre><code>public override func viewDidLoad() {
      super.viewDidLoad()
      self.view.bringSubview(toFront: self.tabBar)
  }
  </code></pre>
  
  <p>And <code>self.tabBar</code>:</p>
  
  <pre><code>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
  }()
  </code></pre>
  
  <p>And this show <code>UITabBar</code> like this:</p>
  
  <p><a href="https://i.stack.imgur.com/QArUJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QArUJ.png" alt="enter image description here"></a></p>
  
  <p>And it's too small cause it's not taking safe areas into consideration. So I did change line:</p>
  
  <pre><code>tab.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>tab.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor).isActive = true
  </code></pre>
  
  <p>And it's then shown like this:</p>
  
  <p><a href="https://i.stack.imgur.com/sL8SM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sL8SM.png" alt="enter image description here"></a></p>
  
  <p>So it's also not shown as expected. The goal here is sth like this:</p>
  
  <p><a href="https://i.stack.imgur.com/oCL5s.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oCL5s.png" alt="enter image description here"></a></p>
  
  <p>How to make constraints to show <code>UITabBar</code> like this?</p>