淡出的UITextField文本 [英] Fade UITextField text

查看:113
本文介绍了淡出的UITextField文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使文本淡入为UITextField当我改变它。我试过

I want to be able to make the text fade in a uitextfield when I change it. I've tried

[UIView animateWithDuration:0.25 animations:{

    textview.text = @"";

}];

但没有奏效。这将是更容易,如果我能访问文本框的UILabel,但我不瑟的!

but that didn't work. It would be easier if I could access the textfields UILabel, but I don't se any!

哦,顺便说一句和我只希望文字褪去不会整场

Oh, and btw, I only want the text to be faded NOT the whole field

任何帮助AP preciated!
- JomanJi

Any help is appreciated! - JomanJi

推荐答案

您需要设置你要它褪色的TextView的值的阿尔法:

You need to set the alpha of "textview" to the value you want to fade it to:

[UIView animateWithDuration:0.25 animations:{
     textview.alpha = 0;
}];

更新:

文本字段本身是不可访问。在文字颜色属性ISA不能设置动画,所以这是出来为好。最好的办法是到图形的造型从标签分离出来,并把它在标签后面的单独视图。这种方式可以淡出标签不删除边框和背景色或者不管你有标签的风格。

The text field itself is not accessible. The "textColor" property isa not animatable, so that's out as well. Your best bet is to separate the graphical styling from the label and put it in a separate view behind the label. This way you can fade out the label without removing the border and BG color or however you have the label styled.

这篇关于淡出的UITextField文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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