SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.32k stars 746 forks source link

Incompatible with application's interface style #474

Closed Eric0625 closed 3 years ago

Eric0625 commented 3 years ago

XCode version: 12.5.1 (12E507) Platform: iOS 14.5 SwiftMessage version: 9.0.2

Hi there. It seems that the appearance of the SwiftMessage is following the system's colour style. It does not comply with the application's overrideUserInterfaceStyle attribute. Below is the code I used, it works for the rest of the app's interface except SwiftMessage views. Thanks.

        let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
        switch userPreferedStyle {
        case .auto:
            keyWindow?.overrideUserInterfaceStyle = .unspecified
        case .dark:
            keyWindow?.overrideUserInterfaceStyle = .dark
        case .light:
            keyWindow?.overrideUserInterfaceStyle = .light
        }
wtmoose commented 3 years ago

You can supply your own colors that adapt to interface style by calling:

MessageView.configureTheme(backgroundColor:foregroundColor:iconImage:iconText:)
Eric0625 commented 3 years ago

You can supply your own colors that adapt to interface style by calling:

MessageView.configureTheme(backgroundColor:foregroundColor:iconImage:iconText:)

I think I've found it, just set MessageView.overrideUserInterfaceStyle to the desired style and it's done.

wtmoose commented 3 years ago

OK, sorry I misread what your problem was. Your message is probably being displayed in its own window and it isn't the key window.

There's a setting for this already – see SwiftMessages.Config.overrideUserInterfaceStyle. But what you did seems fine too.

Eric0625 commented 3 years ago

Thanks