The background of the UIInputView is invisible, and the keyboard animates

I have a text box that has a helper view of UIInputView .

When I touch my text box, and the keyboard flew into view, and I can see a subspecies of viewing accessories, but it does not have a visible background. When the keyboard animation is complete, the UIInputView background appears.

What can I do to make the background of the UIInputView be visible while the keyboard animation is still ongoing?

Here is my code:

UIInputView *inputView = [[UIInputView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, CGRectGetWidth(self.bounds), 44.0f) inputViewStyle:UIInputViewStyleKeyboard]; UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; button.frame = CGRectInset(inputView.bounds, 15.0f, 2.0f); [button setTitle:@"Button" forState:UIControlStateNormal]; [inputView addSubview:button]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 0.0f, CGRectGetWidth(self.bounds), 44.0f)]; textField.inputAccessoryView = inputView; [self addSubview:textField]; 
+8
objective-c uitextfield ios7 inputaccessoryview
source share
1 answer

Not a complete solution, but this effect can be minimized if you set the background of your UIInputView manually inside the -viewDidLoad: method. Fortunately, there is no need to remove it after. Immediately after the appearance of UIInputView will have a really keyboard background and blur effect.

 UIColor *tmpBackground; //Keyboard have color base on the current device. if ([UIDevice isPad] || (UIDevice isPod)]) { //These are my helpers, you have to implement it tmpBackground = [UIColor colorWithRed:207/255.0f green:210/255.0f blue:214/255.0f alpha:1]; } else { tmpBackground = [UIColor colorWithRed:216/255.0f green:219/255.0f blue:223/255.0f alpha:1]; } [textField.inputAccessoryView setBackgroundColor:tmpBackground]; 

PS And I know, this is not an ideal solution for determining color in such a silly way.

+1
source share

All Articles