0

Beginner question! I'd like to set the navigation bar in my app to the same color as the dark keyboard.

I'm setting the app to use only the dark keyboard by calling:

[[UITextField appearance] setKeyboardAppearance:UIKeyboardAppearanceDark];

I would like the color of the navigation bar to match the background color of the keyboard. It's easy enough to change the color of the navigation bar, by calling something like:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0f green:0.4f blue:0.0f alpha:1.0f]];

but I would like to use the same color as the keyboard. Is there a way to specifically call the keyboard color? Or alternatively, would anyone know what the specific value is for the keyboard color?

3 Answers 3

2

Take a look at UIInputView

The UIInputView class is designed to match the appearance of the standard system keyboard when used as an input view with a responder. When defining your own custom input views or input accessory views, you can use a UIInputView object as the root view and add any subviews you want to create your input view. The input view and its subviews receive tinting and blur effects based on the options you specify at initialization time.

1

I don't know about a way to retrieve it natively, but the color is just grey.

[UIColor colorWithRed:.3f green:.3f blue:.3f alpha:1.0f]
1

To properly match the background you really need a semi-transparent view. To approximate it you should place a totally black background under the keyboard and record the white value with Pixie (dev tool google it), then under a white one. By solving two simultaneous linear equations you can work out the appropriate alpha value. Now you have the ability to get the proper look under a solid background.

To get blur you need to subclass uitoolbar - it's the only reusable view currently with blur. See https://github.com/dhoerl/CreateShadowedRoundRectButtonImage For code that does above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.