14

I simply want the keyboard of UITextView to appear in dark mode. However UItextView doesn't have such a property.

Normally for UITextField you can use the following to change the keyboards across the app:

[[UITextField appearance] setKeyboardAppearance:UIKeyboardAppearanceDark];

However when I try the following, app crashes:

[[UITextView appearance] setKeyboardAppearance:UIKeyboardAppearanceDark];

So, my question is simple, is there a way to change keyboard appearance when I use UITextView? I hope and want to believe that Apple didn't forget to add such a feature to UITextView.

Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75
Ömer Faruk Gül
  • 965
  • 1
  • 10
  • 22
  • Is this in your delegate? – Hunter Mitchell Feb 01 '14 at 21:39
  • 2
    Just in case this helps. I also ran into this problem. I was running this code in my AppDelegate just like OP and it would result in a fun error of "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'". I cannot tell you how many places I looked before finally just going line by line in my git diff to find out what changed. This type of crash sucks! – Ceryni Jul 03 '15 at 18:12

1 Answers1

16

There are 2 simple ways to do this

  1. Programmatically

    self.textView.keyboardAppearance = UIKeyboardAppearanceDark;
    
  2. Storyboard or nib file enter image description here

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Xu Yin
  • 3,932
  • 1
  • 26
  • 46