如何为UILabel的textColor属性设置动画? [英] How to animate the textColor property of an UILabel?

查看:364
本文介绍了如何为UILabel的textColor属性设置动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,当我尝试为textColor设置动画时,它将无效。 textColor突然从A变为B.是否可以为它设置动画,从红色到黑色?

For some reason, when I try to animate textColor, it won't work. The textColor just suddenly changes from A to B. Is it possible to animate it, from lets say red to black?

推荐答案

textColour属性未被指定为文档中的动画,所以我认为你不能用简单的UIView动画块来做...

The textColour property is not specified as being animateable in the docs, so I don't think you can do it with a simple UIView animations block...

这可能是非常粗略地用 NSTimer 每隔几毫秒触发一次,每次将颜色逐渐从一个设置到另一个。

This could probably be done pretty crudely with an NSTimer firing every couple of milliseconds, each time setting the colour gradually from one to the other.

我说这很粗糙,因为它需要一个数组或其他一些预设颜色值的容器,从开始颜色到结束颜色,我相信有一种方法可以使用核心动画或其他东西,我只是不知道它是什么。

I say this is crude because it would require an array or some other container of preset colour values going from the start colour to the finish colour, and I'm sure there's a way you could do this using core animation or something, I just don't know what it is.

这篇关于如何为UILabel的textColor属性设置动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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