SwiftKickMobile / SwiftMessages

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

Problem when use "overrideUserInterfaceStyle" on iOS 13 #480

Closed paulocoutinhox closed 1 year ago

paulocoutinhox commented 2 years ago

Hi,

I suggest use:

if #available(iOS 13, *) {
    /// Doing this because there was a issue reported when trying to set the overrideUserInterfaceStyle directly by the normal API.
    if window.responds(to: #selector(setter: UIView.overrideUserInterfaceStyle)) {
        window.setValue(config.overrideUserInterfaceStyle.rawValue, forKeyPath: #keyPath(UIView.overrideUserInterfaceStyle))
    }
}

In this line: https://github.com/SwiftKickMobile/SwiftMessages/blob/c5026484ff555db961ec549162e4026b017aa6c5/SwiftMessages/WindowViewController.swift#L31

Thanks.

cvcoder1 commented 2 years ago

Related to the issue I had, which was closed. @wtmoose

paulocoutinhox commented 1 year ago

The real fix is:

if #available(iOS 13, *) {
    if window.responds(to: #selector(setter: UIView.overrideUserInterfaceStyle)) {
        window.setValue(config.overrideUserInterfaceStyle.rawValue, forKeyPath: #keyPath(UIView.overrideUserInterfaceStyle))
        }
}

On this line: https://github.com/SwiftKickMobile/SwiftMessages/blob/master/SwiftMessages/WindowViewController.swift#L31

See my fix: https://github.com/ubook-editora/SwiftMessages/commit/68bda98d76a00a6f40526df63346e292b8f7bebf

wtmoose commented 1 year ago

Could you please define the actual problem?