ios full screen
This commit is contained in:
@@ -9,4 +9,38 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
) -> UIInterfaceOrientationMask {
|
||||
AppDelegate.orientationLock
|
||||
}
|
||||
|
||||
static func lockOrientation(_ mask: UIInterfaceOrientationMask) {
|
||||
orientationLock = mask
|
||||
guard let scene = UIApplication.shared.connectedScenes
|
||||
.compactMap({ $0 as? UIWindowScene })
|
||||
.first(where: { $0.activationState == .foregroundActive })
|
||||
?? UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).first
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
||||
func update(_ controller: UIViewController?) {
|
||||
guard let controller else { return }
|
||||
controller.setNeedsUpdateOfSupportedInterfaceOrientations()
|
||||
update(controller.presentedViewController)
|
||||
controller.children.forEach { update($0) }
|
||||
}
|
||||
|
||||
let requested: UIInterfaceOrientationMask
|
||||
if mask.contains(.landscapeRight) {
|
||||
requested = .landscapeRight
|
||||
} else if mask.contains(.landscapeLeft) {
|
||||
requested = .landscapeLeft
|
||||
} else {
|
||||
requested = mask
|
||||
}
|
||||
|
||||
scene.windows.forEach { update($0.rootViewController) }
|
||||
scene.requestGeometryUpdate(.iOS(interfaceOrientations: requested)) { _ in }
|
||||
DispatchQueue.main.async {
|
||||
scene.windows.forEach { update($0.rootViewController) }
|
||||
scene.requestGeometryUpdate(.iOS(interfaceOrientations: requested)) { _ in }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user