Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell Smart Invert in iOS 11 not to invert my app colors and detect if it is enabled?

iOS 11 has a new feature called "Smart Invert Colors", and I want to take advantage of that in my app. I already have my own dark mode implemented in my app, so I'll do the "color inversion" process myself when Smart Invert is enabled. What I want to know is:

  • How do I tell iOS 11 that the app has a dark interface and don't invert colours, similar to the iOS Clock app in iOS 10+?
  • How do I detect which kind of Invert Colors, specifically "Smart Invert" or "Classic Invert", is enabled?

I've searched everywhere at Google, StackOverflow, and Apple Developer Website for some time now and still couldn't find the answer.

Thanks in advance!

Update:

Thanks to @Toma's answer, I successfully managed to prevent iOS 11 from inverting views in my app. Now I have another problem...

For the detection part, it appears that UIAccessibility.isInvertColorsEnabled (Swift 4.2) will only return true if Smart Invert is on (iOS 11). At least it's enough for me, for now. I’m now wondering how to find out when Classic Invert is on. Post an updated answer below if you know how to do so! Thanks!

like image 593
LWJ Avatar asked Jun 10 '17 07:06

LWJ


People also ask

How do I invert a specific app on my iPhone?

To use Invert Colors, open the Settings app, then tap Accessibility > Display & Text Size. Turn on Smart Invert or Classic Invert.

What is smart invert colors in iOS 11?

A true “dark mode” to change Apple’s mostly light-colored user interface like the option it has for menus and the dock on macOS is still absent. But in iOS 11, we get the next best thing with a new feature called ‘ Smart Invert Colors’. For many, this feature will satisfy their dark mode needs until an official feature is introduced.

Is Apple getting rid of the invert colors option?

Apple isn’t getting rid of the old invert colors option as some disabled users might prefer it, but it’s changing the name to “Classic Invert” as it introduces the new “Smart” mode.

What is Apple Smart Invert and how do I set it up?

Here’s how to set it up. What Is Smart Invert? Smart Invert is an Apple accessibility feature that inverts the colors on your screen (like a negative image), but with a twist. It’s “smart” because it usually prevents images, videos, and some apps that are already dark-colored from getting inverted.

How to enable Smart Invert on Samsung Galaxy S20?

To enable Smart Invert, open “Settings” and navigate to Accessibility > Display & Text Size. In “Display & Text Size” settings, scroll down until you see “Smart Invert.” Flip the switch beside it to turn it on. Your screen will immediately turn black. After that, exit Settings, and use your apps as usual.


3 Answers

See iOS 11 UIView's property accessibilityIgnoresInvertColors.

like image 50
toma Avatar answered Oct 21 '22 12:10

toma


Ignore smart invert for all UIImageViews. Set in app delegate

if #available(iOS 11.0, *) {
   UIImageView.appearance().accessibilityIgnoresInvertColors = true
}
like image 43
Arnoldas Liudžius Avatar answered Oct 21 '22 14:10

Arnoldas Liudžius


Swift 4.2

To check if it smart invert is currently enabled you can use UIAccessibility.isInvertColorsEnabled. You can also get a notification when it changes by observing UIAccessibility.invertColorsStatusDidChangeNotification:

NotificationCenter.default.addObserver(forName: UIAccessibility.invertColorsStatusDidChangeNotification,
                                       object: nil,
                                       queue: OperationQueue.main) {
                                        [weak self] _ in
  
  if UIAccessibility.isInvertColorsEnabled {
    // smart invert is enabled
  } else {
   
  }
}
like image 5
Orkhan Alikhanov Avatar answered Oct 21 '22 13:10

Orkhan Alikhanov