user1960169 user1960169 - 6 months ago 61
Swift Question

How to add a static bottom view in swift

I want to add a static

UIView
in the bottom of my
UIViewController
. This is a story board app written in swift. in my
viewDidLoad()
I did something like this.

self.vWindow = UIApplication.sharedApplication().keyWindow
let mainBound = CGRectMake(0, self.view.frame.size.height-135, self.view.frame.size.width, 135)//CGSizeMake(UIScreen.mainScreen().bounds.size.width, 135.0)
self.vwVideo = UIView.init(frame: mainBound)
self.vwVideo.backgroundColor = UIColor.blackColor()
self.vWindow.addSubview(self.vwVideo)


But this adds nothing to my
viewController
. Why is that? Please help me.
Thanks

Answer

enter image description here

let vWindow = UIApplication.sharedApplication().keyWindow
let mainBound = CGRectMake(0, self.view.frame.size.height-135, self.view.frame.size.width, 135)//CGSizeMake(UIScreen.mainScreen().bounds.size.width, 135.0)
self.vwVideo = UIView.init(frame: mainBound)
self.vwVideo.backgroundColor = UIColor.blackColor()
vWindow!.addSubview(self.vwVideo)
  • Use this code it will add your view in window at the bottom side.