title: add a button to UIWindow. best Practice?
body: <p>So I have been working on adding a button on to the screen, where it doesn't move at all (even with  scrollView/ Table View).</p>
  
  <p>So, basically a floating action button like in android. </p>
  
  <p>I have used the following libraries, they work fine but have bugs and aren't optimal :</p>
  
  <ul>
  <li>KCFloatingActionButton </li>
  <li>LiquidFloatingActionButton</li>
  </ul>
  
  <p>So I decided to create my own button.
  Now the issue is that I don't know where to add the button. I am using a tab bar controller</p>
  
  <p>I have seen this <a href="https://stackoverflow.com/questions/14689805/how-to-put-buttons-over-uitableview-which-wont-scroll-with-table-in-ios">question</a>.</p>
  
  <p>it proposes following solutions:</p>
  
  <p>1) Use UIViewController instead of UITableVC, but it is not possible for me to do that.</p>
  
  <p>2) The second solution doesn't work since the addition of auto-layout.</p>
  
  <p>3) Another is to add button on navigation Controller if i have a navigation controller.</p>
  
  <p>I am personally considering adding it on UIWindow. But I don't know if I should do that. What are the suggestions and best practices for adding a floating action button?</p>
  
  <p>This is what I have tried :</p>
  
  <pre><code>    let fab : UIButton = UIButton()
  
  
      fab.translatesAutoresizingMaskIntoConstraints = false
      fab.center.x = (self.navigationController?.view.center.x)! + (self.navigationController?.view.frame.width)!/2 - 50.0
      fab.center.y = (self.navigationController?.view.center.y)! + (self.navigationController?.view.frame.height)!/2 - 110.0
      fab.frame.size = CGSize(width: 60.0, height: 60.0)
  
  
      self.navigationController?.view.addSubview(fab)
  
      var constraintSet = [NSLayoutConstraint]()
  
      constraintSet.append(fab.centerXAnchor.constraintEqualToAnchor(self.navigationController?.view.centerXAnchor, constant: self.view.frame.width/2 - 50.0))
      constraintSet.append(fab.centerYAnchor.constraintEqualToAnchor(self.navigationController?.view.centerYAnchor, constant: self.view.frame.height/2 - 110.0))
      constraintSet.append(fab.heightAnchor.constraintEqualToConstant(60.0))
      constraintSet.append(fab.widthAnchor.constraintEqualToConstant(60.0))
      self.navigationController?.view.addConstraints(constraintSet)
  
      fab.layer.zPosition = 3.0
      fab.setImage(UIImage(named: "fab"), forState: .Normal)
  </code></pre>
  
  <p>Here is fab image :  if someone wants to try </p>
  
  <p><a href="https://i.stack.imgur.com/AyiTI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AyiTI.png" alt="enter image description here"></a></p>