如何更改键盘上部的颜色和按钮颜色?
我设置了textfield委托。
然后键盘显示栏,我需要更改栏颜色和按钮。
但我不知道如何设定。
有人可以帮助我吗?非常感谢你。
答案 0 :(得分:0)
1.如果键盘是(将)显示,则将键盘通知添加为否
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(liftMainViewWhenKeybordAppears:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
2.然后在liftMainViewWhenKeybordAppears:方法中,您可以更改条形颜色和按钮。
- (void)liftMainViewWhenKeybordAppears:(NSNotification *)notice{
yourBar.backgroundColor = [UIColor redColor];
[yourButton setTitle:@"newTitle" forState:UIControlStateNormal];
}
3.删除通知
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:YES];
[[NSNotificationCenter defaultCenter]removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
}