swift -> App挂起 (HOME到主屏幕) 和 返回到App 监听

//挂起APP, 即 Home 键 监听
        NotificationCenter.default.addObserver(self, selector:#selector(willResionActive),name: NSNotification.Name.UIApplicationWillResignActive,object: nil);
        //重回app 监听
        NotificationCenter.default.addObserver(self, selector:#selector(didBecome),name: NSNotification.Name.UIApplicationDidBecomeActive,object: nil);
//挂起app 监听
    func willResionActive(){
        print("app will hide")
    }
    //重新回到app 监听
    func didBecome(){
        print("didi become")
    }

相关推荐