是否可以在iOS的UITextField中更改默认选择颜色? [英] It's Possible to change default selection color in UITextField iOS?

查看:331
本文介绍了是否可以在iOS的UITextField中更改默认选择颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认选择颜色为蓝色-我需要将其更改为透明颜色?

Default selection color is blue as - I required to change it clear color?


我知道如果更改色泽颜色,则当我选择蚂蚁文字时会设置该颜色,但是我的问题当我将透明色设置为色泽颜色时,应该没有显示用于选择文本的颜色,但是它将灰色表示为默认值.

如果可行,那怎么办?并请提供源代码.


这是浅色为蓝色时发生的情况


I know If I change tint color then that color will be set when I select ant text but my question When I set clear color as tint color then there should be no color displaying for selection of text but It is taking gray color as default.

if It is posiible then How? and please provide source code.


This is what happens when tint color is blue



如果我设置tintColor =清除颜色,而不是显示灰色.
这种情况是在将色调颜色设置为纯色时发生的,将我不希望的默认颜色设为灰色



if i set tintColor = clear color than display gray color.
This happens when tint color is set as clear color, its taking gray color as default that I dont want

textField.tintColor = [UIColor clearColor];



请帮助我.
预先谢谢!!!



Please help me.
Thanks in advance!!!

推荐答案

这是不可能的,因为如果更改光标颜色以使其清除,它将不会显示所选文本,因此您必须为此选择一些颜色.您可以通过指定其RGB值来使用非常接近透明的颜色.

Its not possible because if you change the cursor color to clear it will not show you the selected text so you have to pick some color for this. You can use a color wchich is very close to transparent by giving its RGB value.

使用下面的代码行

 textfield.tintColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];

它看起来像这样

这篇关于是否可以在iOS的UITextField中更改默认选择颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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