Skip to content

Instantly share code, notes, and snippets.

@amfathi
Last active April 15, 2021 14:19
Show Gist options
  • Save amfathi/7b9af40555c72429cfe4ff3bac347bb4 to your computer and use it in GitHub Desktop.
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.
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