How to get resolution change event in swift?

前端 未结 3 402
臣服心动
臣服心动 2021-01-21 12:09

I try to make an app, and now i shoud make some changes when screen resolution will change, but i coudn\'t find how to intercept this event.

Do you have any ideea ho

3条回答
  •  臣服心动
    2021-01-21 12:44

    Here is the updated Swift 3 code:

     NotificationCenter.default.addObserver(forName: NSNotification.Name.NSApplicationDidChangeScreenParameters,
                                                                object: NSApplication.shared(),
                                                                queue: OperationQueue.main) {
                                                                    notification -> Void in
                                                                    print("screen parameters changed")
        }
    

提交回复
热议问题