From bcc88e545989971ec8de5700336e3249d010a8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josman=20Pe=CC=81rez=20Expo=CC=81sito?= Date: Sat, 21 Mar 2020 17:50:36 +0100 Subject: [PATCH] Added option in the constructor to define whether or not you want the statusBarStyle to be white or default. Because when you have you iOS app with light status bar and the PMAlertController popups it changes to default (black), with this fix is optional to the user. --- Library/PMAlertController.swift | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Library/PMAlertController.swift b/Library/PMAlertController.swift index c0d5661..dc7d4ea 100755 --- a/Library/PMAlertController.swift +++ b/Library/PMAlertController.swift @@ -13,6 +13,11 @@ import UIKit case walkthrough //The alert will adopt a width of the screen size minus 18 (from the left and right side). This style is designed to accommodate localization, push notifications and more. } +@objc public enum PMAlertControllerPreferredStatusBarStyle: Int { + case light + case normal +} + @objc open class PMAlertController: UIViewController { // MARK: Properties @@ -41,6 +46,20 @@ import UIKit open var textFields: [UITextField] = [] + var statusStyle: PMAlertControllerPreferredStatusBarStyle = .normal { + didSet { + self.setNeedsStatusBarAppearanceUpdate() + } + } + open override var preferredStatusBarStyle: UIStatusBarStyle { + switch statusStyle { + case .normal: + return UIStatusBarStyle.default + case .light: + return UIStatusBarStyle.lightContent + } + } + @objc open var gravityDismissAnimation = true @objc open var dismissWithBackgroudTouch = false // enable touch background to dismiss. Off by default. @@ -60,11 +79,11 @@ import UIKit //MARK: - Initialiser - @objc public convenience init(title: String?, description: String?, image: UIImage?, style: PMAlertControllerStyle) { + @objc public convenience init(title: String?, description: String?, image: UIImage?, style: PMAlertControllerStyle, statusBarStyle: PMAlertControllerPreferredStatusBarStyle) { self.init() guard let nib = loadNibAlertController(), let unwrappedView = nib[0] as? UIView else { return } self.view = unwrappedView - + self.statusStyle = statusBarStyle self.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext self.modalTransitionStyle = UIModalTransitionStyle.crossDissolve