简体   繁体   English

更改UITextField的键盘颜色

[英]Change tint color of keyboard for UITextField

I would like to set a custom color for the keyboard that is associated with a UITextField. 我想为与UITextField关联的键盘设置自定义颜色。 I see that I can set the UIKeyboardAppearanceType, but I would like to be able to set the color to arbitrary color, rather than just change to a different default setting. 我看到可以设置UIKeyboardAppearanceType,但是我希望能够将颜色设置为任意颜色,而不仅仅是更改为其他默认设置。 I was hoping it would be as simple as something like this: 我希望它像这样简单:

keyboard.tintColor = [UIColor colorWithRed:...] keyboard.tintColor = [UIColor colorWithRed:...]

Any suggestions? 有什么建议么?

没有公共API可以访问系统键盘,因此您很幸运,没有从头开始重新编写UIKeyboard(这是一个坏主意),或者找到一些私有API来完成这项工作(如果您想要的话,这是一个坏主意)提交到App Store)。

You could use Alert style keyboard and place a view in the background with a background color of your choice. 您可以使用警报样式键盘,并在背景中放置具有您选择的背景色的视图。 This will make the keyboard a different color. 这将使键盘具有不同的颜色。

In Xcode look for the 'Keyboard Look' attribute in the Text Input Traits section of the Attributes Inspector. 在Xcode中,在“属性”检查器的“文本输入特征”部分中查找“键盘外观”属性。 Can toggle between Light/Dark. 可以在明暗之间切换。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM