Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding user interface style (i.e light/dark) on UIMenu

Tags:

ios

I have a simple UIMenu in my app. As expected the interface style updates with the system. However, my app has the option of overriding the system interface style (i.e. light/dark), so I want to be able to override this default behavior.

There is no overrideUserInterfaceStyle property on UIMenu.

I have tried overriding the user interface style of the VC, which didn't work.

None of the solutions from this post work: Is there any way to override the (dark/light) user interface style of iOS 13 Context Menus?

like image 899
mikescott Avatar asked Jan 20 '26 16:01

mikescott


1 Answers

It works for me:

if let keyWindow = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.flatMap { $0.windows }.first { $0.isKeyWindow } {
    keyWindow.overrideUserInterfaceStyle = darkThemeIsNeeded ? .dark : .light
}
like image 144
Artem Avatar answered Jan 22 '26 11:01

Artem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!