【发布时间】:2014-04-07 05:46:35
【问题描述】:
如何改变上键盘栏颜色和按钮颜色?
我设置了文本字段委托。
然后键盘显示栏,我需要更改栏颜色和按钮。
但我不知道如何设置。
有没有人可以帮助我?非常感谢。
【问题讨论】:
标签: xcode button colors keyboard
如何改变上键盘栏颜色和按钮颜色?
我设置了文本字段委托。
然后键盘显示栏,我需要更改栏颜色和按钮。
但我不知道如何设置。
有没有人可以帮助我?非常感谢。
【问题讨论】:
标签: xcode button colors keyboard
1.如果键盘将(确实)显示,则将键盘通知添加到否
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(liftMainViewWhenKeybordAppears:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
2.然后在liftMainViewWhenKeybordAppears:方法中,可以改变Bar Color和Button。
- (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];
}
【讨论】: