当用户点击搜索文本字段时,我想将键盘的颜色更改为黑色。
我试图通过以下方式实现它
UITextField *textField = [UITextField 外观];
[textField setKeyboardAppearance:UIKeyboardAppearanceAlert];
但是我的构建失败并显示此消息
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISearchBarTextField _UIAppearance_setKeyboardAppearance:]: unrecognized selector sent to instance 0x8485260'
请问你能帮我吗? 非常感谢
最佳答案
使用此代码...
for(UIView *searchTextfield in yourSearchBar.subviews)
{
if([searchTextfield isKindOfClass: [UITextField class]]){
[(UITextField *)searchTextfield setKeyboardAppearance: UIKeyboardAppearanceAlert];
}
}
它与我的另一个答案相同,其中我替换了按钮 Image see.. image-for-cancel-button-of-uisearchbar
关于iphone - 更改搜索栏中的键盘颜色和外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16275061/