Search code examples
swiftuiwindowmac-catalyst

How to detect window resizing in Mac Catalyst?


How can I a get a notification when user resize the window while:

 NotificationCenter.default.addObserver(self, selector: #selector(function), name: NSWindowDidResizeNotification, object: nil)

is unavailable in Mac Catalyst


Solution

  • Just like in iOS. Use windowScene(_:didUpdate:interfaceOrientation:traitCollection:) in your window scene delegate, or implement viewWillTransition(to:with:) in your view controllers.