8

I am using Xcode 5 for developing applications. I want to change the color of keyboard in iOS 7. I want a color like black or blue.

How can I change the color of keyboard in iOS 7?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anuj Kumar Rai
  • 666
  • 1
  • 6
  • 17

4 Answers4

23

You can only set the keyboard appearance to any of three listed below using the UIKeyboardAppearance.

UIKeyboardAppearanceDefault  // Corresponds to the UIKeyboardAppearanceLight
UIKeyboardAppearanceDark     // Available in iOS 7.0 and later.
UIKeyboardAppearanceLight    // Available in iOS 7.0 and later.

There is one more constant named UIKeyboardAppearanceAlert but, that is now deprecated. You should use UIKeyboardAppearanceDark instead.

You can't use any custom or undefined color. So, Use ...

myTextfield.keyboardAppearance = UIKeyboardAppearanceDark;
Bhavin
  • 27,155
  • 11
  • 55
  • 94
12

In iOS 7, since the keyboard is translucent, I was able to accomplish this effect by adding a colored subview behind the keyboard that shows and hides with keyboard notifications.

I created a GitHub project to demonstrate this technique. Keep in mind it only works in portrait orientation right now and obviously only in iOS 7.

https://github.com/meekapps/TintedKeyboard

Enter image description here

Community
  • 1
  • 1
Keller
  • 17,051
  • 8
  • 55
  • 72
  • That looks, really awesome, actually! – JomanJi Jan 29 '14 at 19:29
  • Based on the "You can only use `UIKeyboardAppearanceDark` and `UIKeyboardAppearanceLight`" comments, I think this is the closest possible thing to answering the original question. – Kevin Mar 04 '15 at 09:51
4

You can change the color with the keyboardAppearance method.

_textField.keyboardAppearance = UIKeyboardAppearanceDark;

Have a look at the Apple API docs

patrickS
  • 3,590
  • 4
  • 29
  • 40
2

Per your comment of wanting a custom color:

You could do this... Just use the normal keyboard, then observe UIKeyboardWillShowNotification and UIKeyboardWillHideNotification so that you can show a color UIView behind the keyboard.

It would be hacky, but it would work because the default keyboard is transparent to a degree on iOS 7.

Good luck.

Josh Barrow
  • 136
  • 2
  • 5