Last active
April 15, 2021 14:19
-
-
Save amfathi/7b9af40555c72429cfe4ff3bac347bb4 to your computer and use it in GitHub Desktop.
[Tutorial] Example on how use `UIView.transition()` to transition views into each others.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIApplication { | |
static func setRootController(_ viewController: UIViewController) { | |
guard | |
let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene, | |
let window = scene.windows.filter({ $0.isKeyWindow }).first | |
else { return } | |
window.rootViewController = viewController | |
UIView.transition(with: window, duration: 0.25, options: .transitionCrossDissolve, animations: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment