How to enable smart invert for UIView in dark mode?

My app supports dark mode partially.

Most views are using systemBackgroundColor & labelColor so that they are looking great in dark mode.

A document view shows the color components as is.


Before iOS 13, customers can enable smark invert so that they can see smart inverted document view.

After iOS 13, customers can not see smart inverted document view because the other views are using systemBackgroundColor & labelColor.

In this case, I want to enable smart invert for the document view only in dark mode.


How to enable smart invert for UIView in dark mode?

Is it impossible? or do I need to develop it by myself?


Thanks in advance~ ^^

I did some rapid test on one of my apps, when in dark mode, smart invert has no visible effect (in simulator, may be different on device).


However, they state in doc https://www.apple.com/lae/accessibility/iphone/vision/

And the Accessibility preferences for increased contrast and reduced transparency work with Dark Mode enabled.

So, I assume contrast increases on device.


What do you want to get precisely in dark mode after smart invert ? Do you want to return to smart invert as applied on light mode ?


If so, I would try:

- test for accessibility smart invert (even though I've not yet found in doc how to)

- if ON, set your view controllers to light (in viewDidLoad or viewWillAppear)

        overrideUserInterfaceStyle = .light

Thank you for your kind response.


Your suggestion is great but it does not work in iOS 13.2.


I did try to use overrideUserInterfaceStyle = .light but it's not working in dark mode.


I am still looking for a solution~ ^^

What do you expect precisely in dark mode after smart invert ?


I did try to use overrideUserInterfaceStyle = .light but it's not working in dark mode.

Could you explain what you expected, what you get ?


Did you do the tests on device, not on simulator ?

What do you expect precisely in dark mode after smart invert ?


Simply my customer wants to use smart invert in dark mode the same as in iOS 12.x light mode.


Did you do the tests on device, not on simulator ?


Sure, I did test on 4 devices not a simulator.

>customer wants to use smart invert in dark mode


Given this admontion in iOS 13.x Settings (and your mention of it above), I'm not sure your client's ad-hoc want will make it past review:


"Smart Invert Colors reverses the color of the display, except for images, media and some apps that use dark color styles."


As well, devs are encouraged to work with the HIGs, which say this about SI:


"Respond correctly to Invert Colors. People can turn on Invert Colors when they prefer to view items on a dark background. In the Smart Invert mode of Invert Colors, images, video, and full-color icons (such as app icons and nontemplate images) don't invert, and dark UI stays dark."


Looks to me that Apple has specific expectations for SI use that are user (people), not dev, centric. You may need to advise your client against casual attempts at UI changes such as this, and head off a risky review/reject cycle.

How to enable smart invert for UIView in dark mode?
 
 
Q