美文网首页
swift 添加UIWindow三部曲

swift 添加UIWindow三部曲

作者: 执天 | 来源:发表于2017-08-02 10:40 被阅读0次

1. 申明全局变量。


private var newWindow: UIWindow? // 存储需要被添加的newWindow

private var tempWindow: UIWindow? // 存储当前正在使用的window,当使用完newWindow时还原回来。

2. show


tempWindow = UIApplication.shared.keyWindow

newWindow = UIWindow()

newWindow?.frame = UIScreen.main.bounds // ios8 需要设置frame(忘了是八点几...)

newWindow?.makeKeyAndVisible()

newWindow?.rootViewController = self

3. 还原


newWindow?.resignKey()

newWindow = nil

tempWindow?.makeKeyAndVisible()

相关文章

网友评论

      本文标题:swift 添加UIWindow三部曲

      本文链接:https://www.haomeiwen.com/subject/ysselxtx.html