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

后端 未结 3 1203
滥情空心
滥情空心 2020-12-23 14:04

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 t

相关标签:
3条回答
  • 2020-12-23 14:41

    Ignore smart invert for all UIImageViews. Set in app delegate

    if #available(iOS 11.0, *) {
       UIImageView.appearance().accessibilityIgnoresInvertColors = true
    }
    
    0 讨论(0)
  • 2020-12-23 14:47

    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 {
       
      }
    }
    
    0 讨论(0)
  • 2020-12-23 14:54

    See iOS 11 UIView's property accessibilityIgnoresInvertColors.

    0 讨论(0)
提交回复
热议问题