在文本字段中更改光标的颜色 [英] Change color of cursor in text field

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

问题描述

如何在我的文本字段中更改光标的颜色?

解决方案

code> UITextField 的 c> tintColor 属性。这将影响文本光标的颜色和文本选择突出显示颜色。



您可以在代码中执行此操作...

  textField.tintColor = [UIColor redColor]; 

...或在Interface Builder中:





您还可以使用 UITextField 外观代理对您应用程序中的所有文本字段执行此操作:

  [[UITextField appearance] setTintColor:[UIColor redColor]]; 

下面是模拟器屏幕截图,显示了其他普通iOS 7文本字段的外观,其色调设置为红色


$ b



文字选择屏幕截图




How can I change the color of the cursor in my text field?

解决方案

With iOS 7 you can simply change tintColor property of the UITextField. This will affect both the color of the text cursor and the text selection highlight color.

You can do this in code...

textField.tintColor = [UIColor redColor];

... or in Interface Builder:

You can also do this for all text fields in your app using the UITextField appearance proxy:

[[UITextField appearance] setTintColor:[UIColor redColor]];

Below are simulator screenshots showing what an otherwise ordinary iOS 7 text field looks like with its tint set to red.

Text cursor screenshot:

Text selection screenshot:

这篇关于在文本字段中更改光标的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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