title: Swift add Custom View to screen with UIApplication.shared.keyWindow?.addSubview
body: <p>hope this is an easy one...</p>
  
  <p>I am in a empty new project. </p>
  
  <p>I have added a custom view called MyCustomView:</p>
  
  <pre><code>import UIKit
  
  public class MyCustomView: UIView{
  
  private var littleView: UIView!
  
  open class func show() -&gt; UIView{
  
      let bigView = MyCustomView()
  
      bigView.configureView()
      UIApplication.shared.keyWindow?.addSubview(bigView)
  
      return bigView
  }
  
  private func configureView(){
  
      let screenSize = UIScreen.main.bounds.size
      self.frame = CGRect(x: 0,
                          y: 0,
                          width: screenSize.width,
                          height: screenSize.height)
  
      littleView = UIView(frame: CGRect(x: 10, y: 10, width: 100, height: 100))
      littleView.backgroundColor = .black
      addSubview(littleView)
  }
  }
  </code></pre>
  
  <p>In the ViewController doing this:</p>
  
  <pre><code> override func viewDidLoad() {
      let test = MyFirstView.show()
   }
  </code></pre>
  
  <p>I hoped this will present the view, but I still have to use <code>self.view.addSubview(test)</code> to see it....</p>
  
  <p>I thought with <code>UIApplication.shared.keyWindow?.addSubview(bigView)</code> and adding a subView to it, it should present the View.</p>
  
  <p>What am I missing?</p>