使用swift判断是否第一次安装
2017-09-18 本文已影响0人
超越时空的思念_8a22
//定义一个BOOL值,将获取的值不会空
let show:Bool = (UserDefaults.standard.object(forKey: "show") != nil)
//判断
if show == false{
//判断赋予的值是否相同
UserDefaults.standard.set(true, forKey: "show")
//初始化
let vc = ViewController()
//添加到根视图
self.window?.rootViewController = vc
}else{
//定义位置
window = UIWindow(frame: UIScreen.main.bounds)
//背景颜色
window?.backgroundColor = UIColor.white
//进入跳转页面的位置
window?.rootViewController = DiBuViewController()
//定义key值
window?.makeKeyAndVisible()
}