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
Swift 4:
The didChangeScreenParametersNotification
is posted when the configuration of the displays attached to the computer is changed.
Inside the func applicationDidFinishLaunching()
in AppDelegate class or func viewDidLoad()
in ViewController class, insert the following code:
NotificationCenter.default.addObserver(forName: NSApplication.didChangeScreenParametersNotification,
object: NSApplication.shared,
queue: OperationQueue.main) {
notification -> Void in
print("screen parameters changed")}
I personally, used it to center the position of my application when switching between the Mac and the external screen.