アイデアは次のとおりです。既存のキーボードを自分のニーズに合わせて変更します。まず、画面に表示されたときに通知されるように登録します。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(modifyKeyboard:)
name:UIKeyboardWillShowNotification
object:nil];
次に、あなたのmodifyKeyboard方法で:
- (void)modifyKeyboard:(NSNotification *)notification
{
UIView *firstResponder = [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(firstResponder)];
for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows])
for (UIView *keyboard in [keyboardWindow subviews])
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
{
MyFancyKeyboardView *customKeyboard = [[MyFancyKeyboardView alloc] initWithFrame: CGRectMake(0, 0, keyboard.frame.size.width, keyboard.frame.size.height);
[keyboard addSubview: customKeyboard];
[customKeyboard release];
}
}
これにより、元のキーボードの上にビューが追加されるため、必ず不透明にしてください。