It's Possible to change default selection color in UITextField iOS?

雨燕双飞 提交于 2020-01-06 21:09:25

问题


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



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!!!


回答1:


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.

Use below line of code

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

It will look like this




回答2:


Change tint color of the text field.



来源:https://stackoverflow.com/questions/42341269/its-possible-to-change-default-selection-color-in-uitextfield-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!