swift--获取window

有时候,我们需要频繁的调用界面,然后给当前页面加一个跟视图,这个时候就需要找windown,

代码如下:

 let rootVC = UIApplication.shared.delegate as! AppDelegate
 rootVC.window?.rootViewController = MainVC()

这样即可!仅供参考!

原文地址:https://www.cnblogs.com/hero11223/p/7691640.html