Files

42 lines
780 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// Window+Get.swift
// PlusBank
//
// Created by Рустам Мотыгуллин on 25.05.2021.
//
import Foundation
import UIKit
extension UIWindow {
static var current: UIWindow? {
if #available(iOS 13.0, *) {
return UIApplication.shared.windows.filter {$0.isKeyWindow}.first
} else {
return UIApplication.shared.keyWindow
}
}
static var root: UIViewController? {
UIWindow.current?.rootViewController
}
static var nav: UINavigationController? {
if let nav = root as? UINavigationController {
return nav
} else {
return nil
}
}
static var top: UIViewController? {
if let nav = UIWindow.nav {
if let vc = nav.topViewController {
return vc
}
}
return nil
}
}