UITextView KeyboardAppearance property to set UIKeyboardAppearanceDark
Asked Answered
B

1

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.

Bohlen answered 1/2, 2014 at 21:29 Comment(2)
Is this in your delegate?Picaroon
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!Mare
M
16

There are 2 simple ways to do this

  1. Programmatically

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

Moppet answered 1/2, 2014 at 21:58 Comment(1)
Too bad you have to do this for every textview you have in the appCampinas

© 2022 - 2024 — McMap. All rights reserved.