How do I check if Stage Manager is enabled in my code? And I want to turn the Stage Manager on or off with code.
How do I check whether Stage Manager is enabled?
If you just want to check if Stage Manager is enabled this code might help.
But, this process is not perfect.
can not switch on/off.
// AppDelegate version
var isStageManager: Bool {
guard UIDevice.current.userInterfaceIdiom == .pad,
let appDelegate = UIApplication.shared.delegate as? AppDelegate,
let screenHeight = appDelegate.window?.windowScene?.screen.bounds.height,
let windowHeight = appDelegate.window?.bounds.height else { return false }
return screenHeight > windowHeight
}
// SceneDelegate version
var isStageManager: Bool {
guard UIDevice.current.userInterfaceIdiom == .pad,
let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate,
let screenHeight = sceneDelegate.window?.windowScene?.screen.bounds.height,
let windowHeight = sceneDelegate.window?.bounds.height else { return false }
return screenHeight > windowHeight
}