title: How to detect Light\Dark mode change in iOS 13?
body: <p>Some of the UI setups not working automatically with the Dark/Light mode change as the <code>UIColor</code>. For example <code>shadow</code> in layer. As I need to remove and drop shadow in dark and light mode, I need somewhere to put <code>updateShadowIfNeeded()</code> function. I know how to detect what is the mode currently:</p>
  
  <pre><code>func dropShadowIfNeeded() {
      switch traitCollection.userInterfaceStyle {
      case .dark: removeShadow()
      case .light: dropShadowIfNotDroppedYet()
      default: assertionFailure("Unknown userInterfaceStyle")
      }
  }
  </code></pre>
  
  <p>Now I put the function inside the <code>layoutSubviews</code>, since it gets called every time appearance change:</p>
  
  <pre><code>override func layoutSubviews() {
      super.layoutSubviews()
      dropShadowIfNeeded()
  }
  </code></pre>
  
  <p>But this function is getting called <strong>A LOT</strong>. What is the proper function to trigger only if <code>userInterfaceStyle</code> changed?</p>