Objective c 当键盘设置动画时,UIInputView背景不可见

Objective c 当键盘设置动画时,UIInputView背景不可见,objective-c,ios7,uitextfield,inputaccessoryview,Objective C,Ios7,Uitextfield,Inputaccessoryview,我有一个文本字段,它有一个输入附件视图 当我点击我的文本字段时,键盘飞入视图,我可以看到附件视图的子视图,但它没有可见的背景。 键盘动画完成后,UIInputView的背景将弹出到视图中 当键盘动画仍在进行时,如何强制UIInputView的背景可见 这是我的密码: UIInputView *inputView = [[UIInputView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, CGRectGetWidth(se

我有一个文本字段,它有一个输入附件视图

当我点击我的文本字段时,键盘飞入视图,我可以看到附件视图的子视图,但它没有可见的背景。 键盘动画完成后,UIInputView的背景将弹出到视图中

当键盘动画仍在进行时,如何强制UIInputView的背景可见

这是我的密码:

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];

这不是一个完整的解决方案,但如果您在
-viewDidLoad:
方法中手动设置UIInputView的背景,则此影响可以最小化。幸运的是,没有必要删除它后。在出现UIInputView之后,它将具有真正的键盘背景和模糊效果

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];

另外,我知道,用如此愚蠢的方式定义颜色并不是一个完美的解决方案。

我也想在这里看到答案。这真令人不安。