How to change the background color of keypad in iOS 7 - iphone

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?

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;

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

You can change the color with the keyboardAppearance method.
_textField.keyboardAppearance = UIKeyboardAppearanceDark;
Have a look at the Apple API docs

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.

Related

UIButton has strange unexpected bakground color on different device

I've recently been building an app under iOS 15 (latest as of writing this code), and when I shipped a version of my app to test flight, one of my users sent me a video of the app working, and I noticed, all of my buttons have this strange background highlight effect. Is this some sort of accessibility mode? I've never seen this happen before. In included some screenshots below and the interface builder, there are no custom classes associated to this UIButton. And ALL of the buttons have this effect happening to them.
This other device has a strange background color attached:
But this is how its designed and how it shows up on my device and the simulator:
Here is a screenshot from Interface Builder:
I had a similar problem.
Change the style to default.
And then instead of the tint color, choose the text color.
The background can remain default.. and is therefore transparency.
Tested, works.
Example
Turns out my user had something in iOS accessibility settings turned on, called "Button Shapes". I had no idea...

How to support dark mode in splash screens?

I am trying to support dark mode in a splash screen, which means that I am using a named color inside the LaunschScreen.storyboard file, but I have this error:
Named colors do not work prior to iOS 11.0.
Clearly the problem is that named colors work only in the newer versions of iOS, but there is no easy fix for that. I tried to create a custom view and set the color there, but I just found out that it's not allowed to use custom classes in launch screens. For now the only solution that comes to my mind is to create two separate targets, one for iOS 11+, one for the lower versions but it's a bit overkill and I don't like the idea. Apparently there is no recommendation from Apple on how to support dark mode in launch screen (or at least I couldn't find anything). Any suggestion?
Use systemBackgroundColor for the main view background color.
You can change in Storyboard GUI (no code needed) automatically the system will set the right color in iOS13 and white for previous iOS versions.
PS: for other colors you can use System xxxx Color for standards.
As you said named colors will not work below iOS 11.
[alternative] So, you can create an Image View in Launch screen and set a dark appearance for that image like below.
You can apply your colors in that image.

Setting UIButton stretched background images in Interface Builder (XCode 4)

I'm trying to set up an UIButton background using a stretchable image in Interface Builder. Button is configured as "custom" and I have assigned a background image to it. The view mode is set to "Scale to Fill", but when I set any value in "Stretching" area it doesn't seems to do anything.
I have tried doing it programmatically and it works using the UIImage's stretchableImageWithLeftCapWidth:topCapHeight: message, but its use is not recommended by Apple.
Is there any way to make it work from Interface Builder?
Unfortunately, you can't use stretchable/resizable images in the current version of Xcode 4. You have to do it programmatically.
Assuming that you are talking about iOS 5: the SDK is still under NDA for a few days, so I can't be more specific. But just as a hint:
Apple doesn't discourage the use of stretchableImageWithLeftCapWidth:topCapHeight:. If you look at the documentation (iOS 5 version) of this method again, you will find an answer there.

How can I remove the glossy effect on a UITabbar?

I don't want the glossy selection that is on a standard UITabBar. Is there a way to remove the shine, and possibly add background texture instead of the black?
If your application is to be released on iOS 5, with no backward compatibility needed; goto to http://developer.apple.com and have a look, something on the iOS 5 beta pages might peek your interest :).
Otherwise you need to subclass UITabBar or make an equivalent replacement that draws using your custom needs.

Why are disabled UISegmentedControl segments drawn incorrectly on iOS 4.0+?

For some strange reason, on iOS 4.2.1 (and any iPhone OS after 4.0), using a UISegmentedControl as a UIBarButtonItem in a toolbar will leave disabled segments drawn incorrectly, like this:
The text is displayed in dark gray, but should resemble the disabled state of the disabled "Login" button in the upper right. I'm using a standard UISegmentedControl, not a subclass.
Is there any way to get around this bug?
UPDATE: It's definitely not supposed to look that way and is probably a regression indroduced in iOS 4.0. Here's how it looks on 3.1.3: