title: Darkmode and multiwindows / scenes
body: <p>i'm trying to implement ios13 darkmode within multi scene application.</p>
  
  <p>Unfortunately when i dismiss a scene dragging it over the screen edge the method traitCollectionDidChange is called several times with always different values, causing my UI to flicker between dark and light mode.</p>
  
  <p>What's wrong?</p>
  
  <p>Here is my implementation</p>
  
  <pre><code>func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {  
      super.traitCollectionDidChange(previousTraitCollection)  
  
      print("THEME instance: \(self)")  
  
      let currentTraitCollection = self.traitCollection  
      var hasUserInterfaceStyleChanged = false  
      hasUserInterfaceStyleChanged = previousTraitCollection.hasDifferentColorAppearanceCompared(to: currentTraitCollection)  
  
      print("THEME hasUserInterfaceStyleChanged = \(hasUserInterfaceStyleChanged ? "YES" : "NO")")  
  
      if hasUserInterfaceStyleChanged {  
          let userInterfaceStyle = currentTraitCollection.userInterfaceStyle // Either .unspecified, .light, or .dark  
  
          switch userInterfaceStyle {  
              case .unspecified:  
                  print("THEME UIUserInterfaceStyleUnspecified")  
              case .light:  
                  print("THEME UIUserInterfaceStyleLight")  
              case .dark:  
                  print("THEME UIUserInterfaceStyleDark")  
              }  
      } else {  
          print("THEME NOT CHANGED")  
      }  
  
  }  
  </code></pre>
  
  <p>Here is the logged statements in console</p>
  
  <p>When new scene comes in...</p>
  
  <pre><code>THEME instance: &lt;MainControllerViewController: 0x117e55910&gt;  
  THEME hasUserInterfaceStyleChanged = YES  
  THEME UIUserInterfaceStyleLight  
  </code></pre>
  
  <p>When added scene goes away...</p>
  
  <pre><code>THEME instance: &lt;MainControllerViewController: 0x117e55910&gt;  
  THEME hasUserInterfaceStyleChanged = YES  
  THEME UIUserInterfaceStyleDark  
  THEME instance: &lt;MainControllerViewController: 0x117e55910&gt;  
  THEME hasUserInterfaceStyleChanged = YES  
  THEME UIUserInterfaceStyleLight  
  THEME instance: &lt;MainControllerViewController: 0x117e55910&gt;  
  THEME hasUserInterfaceStyleChanged = NO  
  THEME NOT CHANGED  
  THEME instance: &lt;MainControllerViewController: 0x117e55910&gt;  
  THEME hasUserInterfaceStyleChanged = YES  
  THEME UIUserInterfaceStyleDark  
  THEME instance: &lt;MainControllerViewController: 0x117e55910&gt;  
  THEME hasUserInterfaceStyleChanged = YES  
  THEME UIUserInterfaceStyleLight  
  </code></pre>
  
  <p>in meantime i have no changed to dark mode (always light)...so i expect just THEME NOT CHANGED.</p>