UIKeyBoard 返回按钮 UIReturnKeyDone
textfield.returnKeyTYpe = UIReturnKeyDone
因此,上面的内容使键盘上的“返回”按钮显示“完成”。我在 UIKeyBoard 上看到过带有蓝色按钮的应用程序。这足够简单吗?如何更改 Return 键的背景颜色?
textfield.returnKeyTYpe = UIReturnKeyDone
So the above makes my Return button on the keyboard to say Done. I have seen Apps with Blue color button on the UIKeyBoard. Is that simple enough to do? How do I change the background color of the Return key?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
仅当 Return 键的类型不是
UIReturnKeyDefault
并且启用时,它才会变成蓝色。要确保它已启用,您可以设置textfield.enablesReturnKeyAutomatically = YES
。The Return key only turns blue if it has a type other than
UIReturnKeyDefault
and is enabled. To make sure it gets enabled, you can settextfield.enablesReturnKeyAutomatically = YES
.我不完全确定你可以,如果可以,我认为你可能需要滚动自己的键盘或使用未记录的方法。或者,您可以在按钮上绘制自己的视图,并使其对用户触摸透明。 这篇文章可能会对您有所帮助。
I'm not entirely certain you can, and if you can I think that you might need to either roll your own keyboard or use undocumented methods. Alternatively, you could draw your own view over the button and simply make it transparent to user touches. This article might help you.
一旦用户在
UITextField
中输入代码,返回键背景颜色就会自动变为蓝色。The return key background color turns AUTOMATICALLY into blue as soon as the user enters code for e.g. into a
UITextField
.以下是执行此操作的 Swift 代码:
注意:在调用 addColorToUIKeyboardButton() 之前,请确保键盘可见。
Here's the code in Swift that does the job:
Note: Make sure the keyboard is visible before you call addColorToUIKeyboardButton()