Change iOS System Keyboard Background Image and Buttons Image - ios

Rather than creating a custom keyboard...how can I change the ios keyboard background image and get reference of the keyboard button or just the keyboard view programatically?
I do not want to replicate the whole ios keyboard, just tweak the keyboard here and there.
Solution Update:
You cannot update only the background or the buttons of the iOS System Keyboard! This is dues to the reason that Apple has limited the access to the Keyboard API. The most you can do is change the keyboard background color i.e. dark or light.
If you need to change the background to an image like me, you need to extend the ios keyboard i.e. make your own custom keyboard!
Please check below for accepted answer!
Hope this helps!

You can do something like this,
myTextField.keyboardType = UIKeyboardTypeDecimalPad; // many other options
myTextField.keyboardAppearance = UIKeyboardAppearanceDark; //many other options
If you want totally customize keyboard then refer this tutorial.
Hope this will help :)

For dark background you can use
mytextfield.keyboardAppearance = UIKeyboardAppearanceAlert;
For more customisation follow this link:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html

Related

setTitleTextAttributes not working after view on screen. iOS 11

I've spent a whole day trying to change the colour of a UIBarButtonItem and now i'm thinking it is an iOS 11 bug unless someone can tell me it's by design.
I can change the colour of the text by using this code
[self.refreshButton setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor orangeColor]} forState:UIControlStateNormal];
If I add the code to the viewWillAppear:animated function it works fine, however if you add it to viewDidAppear:animated it does not work.
It seems to work on the iOS 9 simulator, but not iOS 11.
Has something changed in this regard in iOS 11?
If all you want to do is change the title color of your UIBarButtonItem you can set the tintColor property instead of setTitleTextAttributes:. If you want all of your UIBarButtonItems to have the same title color you can set the tintColor of your tool/navigation bar.
I had the same issue on iOS11 but needed to set the font by setTitleTextAttributes. Unfortunately this does also not work by appearance. The only solution I found was to create new BarButtonItems as copy of the old ones and then set them as navigationItem.rightBarButtonItems.
For reference for other users having the same issue.
This Stack Overflow answer may explain why the method doesn't work.
An improper setting of UIControlState() may be the problem.

iOS Swift Notifications action background color

After some search i couldn't find information on how to change notification button background colors. Is this possible to do with Swift in iOS?
Thanks :)
The only thing you can do is to set it to red color. You can achieve it if you set actionButton.destructive equal to true

UIButton with no image doesn't highlight in Xcode 7 - iOS 9.2

I'm making my first app in Swift and I noticed that when I create UIButtons in the storyboard when selected (highlighted) in the app they only change background if the button is an image.
I was wondering if there is any way in Swift to change that so that even the buttons with no image will change their background to a darker background.
Thanks for the help.
UIButton's default behaviour is to change its background on click.
try dragging a new UIButton on Interface Builder, and run the program without doing any changes to the button.
With your specific button, inspect it in Interface Builder and check that its type is System, otherwise you don't get that default behaviour.

keyboard language button in UITextView

Just noticed that in UITextView keyboard comes without change language button, unlike in UITextField. Why Apple removed this button from UITextView keyboard? Is there any way to enable this button? I want people to be able to write notes on any keyboard language added in phone settings.
EDITED: Maybe it will help somebody in the future. Just noticed that I set keyboard type to UIKeyboardTypeAlphabet and this option eliminates language button. Closing this question.
P.S. I have 3 languages enabled in test iPhone.
You are completely wrong. there is no difference in UIKeyboard in iOS whatsoever. It only depends on what keyboard types you use.
UIKeyboardTypeDefault and UIKeyboardTypeEmailAddress and UIKeyboardTypeTwitter all have those.
You set it like this:
txtField.keyboardType = UIKeyboardTypeTwitter;
UIKeyboardTypeDefault is obviously the default one for any UITextView or UITextField in iOS.
For anyone have this problem even when using UIKeyboardTypeDefault on a UITextView, go into the storyboard and make sure "Secure Text Entry" is unchecked. After unchecking this, the keyboard selector will return as well as the quick type keyboard.

invert UIDatePicker colors in iOS 7

I want to start by saying that i would post this question on the Apple Dev Forums but because of the hacking attempt fiasco , or whatever that was, the forum has been offline for almost 2 weeks now and i need a solution for this as soon as possible.
In iOS 7 the UIDatePicker looks like this :
and a client asked to look like this :
(basically inverted).
I've tried a few things:
Setting the background to black and looping through all the view's subviews until i reach the labels that show the date itself and change their color to white. The problem is that The view has only one subview, and that subview doesn't have any subviews of it's own. So this solution doesn't work. (it did in ios6).
Applying a filter to the view's CALayer. The thing is that this is only possible on OS X not on iOS, for some unknown reason.
Playing with UIApperance protocol. From what i've read this should work but what i've tried didn't and i don't have extensive experience with this to figure out why not.
Any ideas what i can try? Is this even possible? Did i made a mistake in my approach of the problem?
Try this out :
Put this code in -(void)viewDidLoad
[datePicker setValue:[UIColor whiteColor] forKey:#"textColor"];
Swift:
datePicker.setValue(UIColor.white, forKey: "textColor")
Don't know if this is still relevant but on Swift 3 / Xcode 8 you can simply do this:
let datePicker = UIDatePicker()
datePicker.datePickerMode = UIDatePickerMode.date
// Sets the text color
datePicker.setValue(UIColor.white, forKey: "textColor")
// Sets the bg color
datePicker.backgroundColor = UIColor.black.withAlphaComponent(0.6)
textField.inputView = datePicker
I spent quite a bit of time struggling with the same problem. At first, I've put a UIDatePicker on a black background and was wondering why it is invisible...
I ended up placing a white UIView as a background for the date picker, so while the whole view is black, the date picker is white. It actually looks okay, although thankfully I don't have a client who would dictate the design.
One possible argument for a client: the old, pre-iOS7 date picker, also had a predefined non-customisable background.
What you want is possible, but it will be called Custom Date Picker.
Below is the link where you will find what you wanted.
https://www.cocoacontrols.com/controls/simpledatepicker
If you need more, take a loot at below link.
https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=datepicker
Well I understand your frustration, but iOS7 is under NDA. Usually this kind of views are made using layers, beacuse of sublayerTransform that can make perspective giving the idea of 3D. I would check sublayers if you don't see subviews.
The other poin is that I would not hack too much views/layers hierachy, ios<=6 to ios7 transition shown that hacking isn't a good idea.
UIAppereance protocol is probably the way to go, becauase it makes you change what you can change (without screwing that in the future), maybe you can set a backgroundImage, try to set a 1x1pixel of a blck color png, you should also see an attributed string property, or text property.
I dont think its possible to do that directly by changing the properties of the default UIDatePicker , although you can use custom controls to do it.
This might help,
MWDatePicker - https://github.com/mwermuth/MWDatePicker (Found it in cocoa controls -https://www.cocoacontrols.com/controls/mwdatepicker)
according to the iOS Design Resources:
You cannot customize the appearance of date pickers.
I would suggest one of the below:
Redesign your UI to use the black text
Use a customer datepicker
You should tell your client that his suggestion is against the design principles of iOS 7, which indeed it is. I am not a great fan of iOS 7 myself, but we should all give it a go. Your client should accept the standard iOS 7 UI provisionally, until he is in a position to make an informed judgement. Designing an app based on his initial impressions is a recipe for disaster.

Resources