How do you get the current scene's status bar height for use in a SwiftUI view?
It looks like the key is accessing the current scene. From a view controller, you can use view.window?.windowScene
to get to the scene, but what about in a SwiftUI view?
Store the window scene in an environment object when creating the view hierarchy. The environment object can be an existing object that you use for other app-wide data.
Set the window scene when you create the environment object. Add the object to the view at the base of your view hierarchy, such as the root view.
Finally, use the window scene to access the status bar height.