Search code examples
iphoneiosios6uitextfield

Is it possible to customize the keyboard from UITextField?


I have a view controller where my keyboard is on screen for the entire time. Because of this, I was hoping to make it's height a bit smaller, and it's also a game app so I was hoping to make the keyboard look more gamey.

How should I approach this? Can I customize the keyboard this much in code? Should I try to make my own keyboard with more than 20 custom buttons to form a keyboard?


Solution

  • Garrett is correct, you cannot customize the standard iOS keyboards, there is however a way to provide a custom view in its place.

    UITextField has a property on it called inputView

    That will allow you to provide the view you want while still keeping the nicety of using the textfield to become and resign first responder.

    Since you stated the keyboard is always open in the app, I am assuming you are only created/setting the UITextField once.

    So, in viewDidLoad bring up the keyboard so it stays on screen and set it's inputView.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
        UIView *customKeyboardView = [[[NSBundle mainBundle] loadNibNamed:@"CustomKeyboard" owner:nil options:nil] lastObject];
        self.myTextField.inputView = customKeyboardView;
    
        [self.myTextField becomeFirstResponder];
    }