diff --git a/Pod/Classes/ZAlertView.swift b/Pod/Classes/ZAlertView.swift index c9a9bf2..aa01031 100644 --- a/Pod/Classes/ZAlertView.swift +++ b/Pod/Classes/ZAlertView.swift @@ -441,7 +441,7 @@ import UIKit } self.height += ZAlertView.padding - let bounds = UIScreen.main.bounds + let bounds = self.backgroundView.bounds self.alertView.frame = CGRect(x: bounds.width/2 - width/2, y: bounds.height/2 - height/2, width: width, height: height) } @@ -882,4 +882,19 @@ import UIKit } } + + override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + self.perform(#selector(self.updateFrame), with: nil, afterDelay: 0.2) + } + + /// Update background view frame + @objc func updateFrame() { + guard let window = UIApplication.shared.keyWindow else { + return + } + print(window.bounds) + self.backgroundView.frame = window.bounds + } } +