|
@@ -15,6 +15,7 @@ import KingfisherWebP
|
|
|
import Photos
|
|
|
import Toast_Swift
|
|
|
import RealmSwift
|
|
|
+import UIKit
|
|
|
|
|
|
/// Home文件地址
|
|
|
public let homeDirectory = NSHomeDirectory()
|
|
@@ -132,6 +133,36 @@ public func kf_imageCacheImage(originUrl: String, completeHandle: @escaping (_ i
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+public func bf_getRootViewController() -> UIViewController? {
|
|
|
+ guard let window = UIApplication.shared.delegate?.window else {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return window!.rootViewController
|
|
|
+}
|
|
|
+
|
|
|
+public func bf_getCurrentViewController() -> UIViewController? {
|
|
|
+ var currentVC = bf_getRootViewController()
|
|
|
+ if currentVC == nil {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ let runloopFind = true
|
|
|
+ while runloopFind {
|
|
|
+ if let vc = currentVC!.presentedViewController {
|
|
|
+ currentVC = vc
|
|
|
+ }else {
|
|
|
+ if currentVC is UINavigationController {
|
|
|
+ currentVC = (currentVC as! UINavigationController).visibleViewController
|
|
|
+ }else if currentVC is UITabBarController {
|
|
|
+ currentVC = (currentVC as! UITabBarController).selectedViewController
|
|
|
+ }else {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return currentVC
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
/** 打印
|
|
|
type = 1 : 胡志强
|