Skip to content

Instantly share code, notes, and snippets.

@artemnovichkov
Last active December 11, 2020 22:49
Show Gist options
  • Save artemnovichkov/64f69746d0d302ab725ea63c31914a6d to your computer and use it in GitHub Desktop.
Save artemnovichkov/64f69746d0d302ab725ea63c31914a6d to your computer and use it in GitHub Desktop.
Updating application with new user interface style
import UIKit
public extension UIApplication {
func override(_ userInterfaceStyle: UIUserInterfaceStyle) {
if supportsMultipleScenes {
for connectedScene in connectedScenes {
if let scene = connectedScene as? UIWindowScene {
for window in scene.windows {
window.overrideUserInterfaceStyle = userInterfaceStyle
}
}
}
}
else {
for window in windows {
window.overrideUserInterfaceStyle = userInterfaceStyle
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment