@@ -120,7 +120,9 @@ open class SPAlertView: UIView {
120120
121121 private func commonInit( ) {
122122 preservesSuperviewLayoutMargins = false
123- insetsLayoutMarginsFromSafeArea = false
123+ if #available( iOS 11 . 0 , * ) {
124+ insetsLayoutMarginsFromSafeArea = false
125+ }
124126 layer. masksToBounds = true
125127 layer. cornerRadius = 8
126128 backgroundColor = . clear
@@ -140,15 +142,19 @@ open class SPAlertView: UIView {
140142 fileprivate var defaultContentColor : UIColor {
141143 let darkColor = UIColor ( red: 127 / 255 , green: 127 / 255 , blue: 129 / 255 , alpha: 1 )
142144 let lightColor = UIColor ( red: 88 / 255 , green: 87 / 255 , blue: 88 / 255 , alpha: 1 )
143- guard let interfaceStyle = self . window? . traitCollection. userInterfaceStyle else {
145+ if #available( iOS 12 . 0 , * ) {
146+ guard let interfaceStyle = self . window? . traitCollection. userInterfaceStyle else {
147+ return lightColor
148+ }
149+ switch interfaceStyle {
150+ case . light: return lightColor
151+ case . dark: return darkColor
152+ case . unspecified: return lightColor
153+ @unknown default : return lightColor
154+ }
155+ } else {
144156 return lightColor
145157 }
146- switch interfaceStyle {
147- case . light: return lightColor
148- case . dark: return darkColor
149- case . unspecified: return lightColor
150- @unknown default : return lightColor
151- }
152158 }
153159
154160 open func present( duration: TimeInterval = 1.5 , haptic: SPAlertHaptic = . success, completion: ( ( ) -> Void ) ? = nil ) {
0 commit comments