使用apperance在UISearchBar中更改键盘颜色 [英] Change Keyboard Color in UISearchBar with apperance

查看:312
本文介绍了使用apperance在UISearchBar中更改键盘颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点按搜索文本字段时,我想将键盘的颜色更改为黑色。

I want to change the color of the keyboard to black, when the user taps on the search textfield.

我试图用
UITextField * textField = [UITextField appearance];
[textField setKeyboardAppearance:UIKeyboardAppearanceAlert];

但我的构建失败并显示此消息

but my build fails with this message


由于未捕获异常而终止应用程序'NSInvalidArgumentException',reason:' - [UISearchBarTextField _UIAppearance_setKeyboardAppearance:]:无法识别的选择器发送到实例0x8485260'

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISearchBarTextField _UIAppearance_setKeyboardAppearance:]: unrecognized selector sent to instance 0x8485260'

请你能帮我一下吗?
非常感谢

Please can you help me with that? Thanks a lot

推荐答案

使用此代码...

    for(UIView *searchTextfield in yourSearchBar.subviews)
    {
        if([searchTextfield isKindOfClass: [UITextField class]]){
            [(UITextField *)searchTextfield setKeyboardAppearance: UIKeyboardAppearanceAlert];
        }
    }

它像我的另一个答案, button Image see .. image-for-cancel-button-of-uisearchbar

its same like my another answer in which i replace the button Image see.. image-for-cancel-button-of-uisearchbar

这篇关于使用apperance在UISearchBar中更改键盘颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆