更改 UITextField 和 UITextView 光标/插入符号颜色 [英] Change UITextField and UITextView Cursor / Caret Color
本文介绍了更改 UITextField 和 UITextView 光标/插入符号颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何更改 iOS 中 UITextField
(如果答案相同,则 UITextView
)中光标/插入符号的颜色.我看到了 OSX 开发的答案,但没有看到 iOS 的答案.
I'm wondering about changing the color of the cursor / caret in a UITextField
(And UITextView
if its the same answer) in iOS. I've seen answers for OSX development, but nothing for iOS.
这甚至可能吗?
推荐答案
如果您的目标是 iOS 7+,这已经变得更容易了.只需使用外观代理通过光标更改字段的 tintColor
,它就会应用于整个应用程序:
If you're targeting iOS 7+, this has been made much easier. Simply change the tintColor
of the field with a cursor using the appearance proxy and it will apply throughout the app:
斯威夫特 3.0:
UITextField.appearance().tintColor = .black
目标-C:
[[UITextField appearance] setTintColor:[UIColor blackColor]];
相同的答案适用于单个 UITextField
:
Same answer applies for an individual UITextField
:
斯威夫特 3.0:
myTextField.tintColor = .black
目标-C
[myTextField setTintColor:[UIColor blackColor]];
这篇关于更改 UITextField 和 UITextView 光标/插入符号颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文