         #if EXTENSION
             return customSuperview
         #else
-            return customSuperview ?? UIApplication.shared.keyWindow
+            if #available(iOS 13, *) {
+                return customSuperview ?? UIApplication.shared.windows.first{ $0.isKeyWindow }
+            } else {
+                return customSuperview ?? UIApplication.shared.keyWindow
+            }
         #endif
     }
 

                })
        })
    }

    @objc public func updateFrame() {
        if let containerView = SwiftSpinner.containerView() {
            SwiftSpinner.shared.frame = containerView.bounds
            containerView.bringSubviewToFront(SwiftSpinner.shared)

                // Orientation change observer
                NotificationCenter.default.addObserver(
                    spinner,
                    selector: #selector(SwiftSpinner.orientationChangedAction),
                    name: UIDevice.orientationDidChangeNotification,
                    object: nil)
            #endif
        } else if spinner.dismissing {
