From 9c6b79df12305ef89435c42a91b38a9ebc7fde6b Mon Sep 17 00:00:00 2001 From: Petr Pavlik Date: Tue, 28 Sep 2021 16:52:26 +0200 Subject: [PATCH] Fix iOS 15 crash --- Source/AlertVisualStyle.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/AlertVisualStyle.swift b/Source/AlertVisualStyle.swift index 0b6727d..dd24b6e 100644 --- a/Source/AlertVisualStyle.swift +++ b/Source/AlertVisualStyle.swift @@ -154,7 +154,7 @@ open class AlertVisualStyle: NSObject { switch alertStyle { case .alert: - if #available(iOS 11, *), UIApplication.shared.keyWindow!.safeAreaInsets.bottom > 0 { + if #available(iOS 11, *), UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 > 0 { self.margins = .zero } else { self.margins = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0) @@ -164,7 +164,7 @@ open class AlertVisualStyle: NSObject { self.actionViewSize = CGSize(width: 90, height: 44) case .actionSheet: - if #available(iOS 11, *), UIApplication.shared.keyWindow!.safeAreaInsets.bottom > 0 { + if #available(iOS 11, *), UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 > 0 { self.margins = UIEdgeInsets(top: 30, left: 10, bottom: 0, right: 10) } else { self.margins = UIEdgeInsets(top: 30, left: 10, bottom: -10, right: 10)