So basically what I'm trying to do is this:
//Position the window in the center of the screen, initially.
UIScreen *targetScreen = scene.screen;
CGRect initialWindowRect = CGRectMake((targetScreen.bounds.size.width/2.0)-(DEFAULT_SIZE.width/2.0),
targetScreen.bounds.size.height/2.0-(DEFAULT_SIZE.height/2.0),
DEFAULT_SIZE.width,
DEFAULT_SIZE.height);
Sometimes the origin is ignored (depending whether or not another window is opened, the system adds a default space between open windows. Typically this is how "New Document" windows open on Mac but you wouldn't always want this behavior (for example the "Welcome to Xcode" window always positions itself in the center of the screen when opening).
Also is there a way I can compute NSScreen's visibleFrame property from the Mac Catalyst environment so I can position the window relative to the visible frame (the area not including the menu bar and the dock)?
UIScreen.bounds property is (origin = (x = 0, y = 0), size = (width = 1440, height = 900)) but really I'd like to compute the initial window frame relative to NSScreen's .visibleFrame property which would be {{0, 95}, {1440, 780}}
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: