mirror of
https://github.com/devxoul/Toaster.git
synced 2026-01-18 21:21:19 +01:00
Merge pull request #170 from cozzin/preventToBeKeyWindow
Avoid ToastWindow to be keyWindow
This commit is contained in:
@@ -2,7 +2,7 @@ import UIKit
|
||||
|
||||
open class ToastWindow: UIWindow {
|
||||
|
||||
public static let shared = ToastWindow(frame: UIScreen.main.bounds)
|
||||
public static let shared = ToastWindow(frame: UIScreen.main.bounds, mainWindow: UIApplication.shared.keyWindow)
|
||||
|
||||
/// Will not return `rootViewController` while this value is `true`. Or the rotation will be fucked in iOS 9.
|
||||
var isStatusBarOrientationChanging = false
|
||||
@@ -52,9 +52,12 @@ open class ToastWindow: UIWindow {
|
||||
}
|
||||
set { /* Do nothing */ }
|
||||
}
|
||||
|
||||
private weak var mainWindow: UIWindow?
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
public init(frame: CGRect, mainWindow: UIWindow?) {
|
||||
super.init(frame: frame)
|
||||
self.mainWindow = mainWindow
|
||||
self.isUserInteractionEnabled = false
|
||||
self.gestureRecognizers = nil
|
||||
#if swift(>=4.2)
|
||||
@@ -193,6 +196,11 @@ open class ToastWindow: UIWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open override func becomeKey() {
|
||||
super.becomeKey()
|
||||
mainWindow?.makeKey()
|
||||
}
|
||||
|
||||
/// Returns top window that isn't self
|
||||
private func topWindow() -> UIWindow? {
|
||||
|
||||
Reference in New Issue
Block a user