开发者

Changing the text of a UILabel when its superview is being animated

Is it possible to alter the text of a UILabel whist its superview is being animated by UIView animations?

Say I have labelView as a sub view of containerView. timerFired is being called during containerView being animated (never开发者_如何学C before or after). I'm calling setText of labelView during the animation, but its text doesn't change. Is there any way to achieve what I'm after?

Edit: My fault - this works . Problem was with my text updating routine (casting issue).


Your problem is how animations work. Core Animation effectively takes a snapshot of the initial state and a snapshot of the end state and interpolates between them. This is highly efficient, but doesn't easily let you mess with non-animatable properties (like text) in the middle of an animation. There are a number of ways to solve this problem, but the simplest would be to create two labels, animate them together, and animate their opacity or hidden. This will generally give you a cross-fade look, which I assume is what you'd want. Of course there are also lots of ways to achieve this by managing your own CALayers, but the two UILabel solution is the simplest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜