4

When switching between light and dark mode with iOS 13, I am experiencing an unusual behavior with the keyboard showing.

The view has an inputAccessoryView for a user to type in messages. When then light/dark mode is switched with the keyboard showing, the light/dark mode does not reflect on the keyboard until the keyboard is hidden and shown again. Initially this is what I'm seeing when switching between dark and light mode:

enter image description here

After dismissing the keyboard and showing again the color is normal. This only happens on this keyboard with the inputAccessoryView. When the mode is changed with just the inputAccessoryView without keyboard showing the inputAccessoryView colors change as expected.

alionthego
  • 8,508
  • 9
  • 52
  • 125
  • 1
    If you feel this is a bug, file a bug report with Apple. Include a simple test app that demonstrates the problem with clear instructions for reproducing the issue. – rmaddy Oct 30 '19 at 01:06
  • I have created a simple sample project with the same problem and submitted a bug. I'll update reply here. – alionthego Oct 30 '19 at 01:57
  • Hi, how it is going with this bug? I have tried the same with empty sample app in xcode 11.4 beta 2 and this bad behavior still occurs. – Stanislav K. Feb 25 '20 at 11:18
  • I've filed a bug report but no reply and no fix I'm aware of – alionthego Feb 27 '20 at 01:46

1 Answers1

1

I came across this too. My solution was to resignFirstResponder on the UITextView in the inputAccessoryView when the color appearance changes. Not ideal, but gets round the problem.

(I had to override resignFirstResponder in the messageInputAccessoryView to resignFirstResponder on the textView)

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
    super.traitCollectionDidChange(previousTraitCollection)

    if #available(iOS 13.0, *) {
      if self.traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
        _ = messageInputAccessoryView.resignFirstResponder()
      }
    }
  }
Adam Young
  • 1,217
  • 10
  • 18