To create a new UIWindow over the main window

后端 未结 8 2358

In my app I want to create a new UIWindow over the main UIWindow, And I wrote as following, but it don\'t works. first, i create a UIWindow as the

8条回答
  •  时光说笑
    2020-12-07 22:59

    func createAdsWindow(){
        let frame = CGRect.init(0, UIScreen.main.bounds.height - 60, UIScreen.main.bounds.width, 60)
        adsWindow = UIWindow.init(frame: frame)
        adsWindow!.backgroundColor = UIColor(colorBackground)
        let adsViewController = UIViewController.init()
        adsViewController.view.backgroundColor = UIColor.red
        adsWindow?.rootViewController = adsViewController
        adsWindow?.windowLevel = UIWindow.Level(rawValue: 2)
        adsWindow?.makeKeyAndVisible()
    }
    

提交回复
热议问题