views:

263

answers:

1

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 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).

+1  A: 

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.

Rob Napier
I feared this may be the case. What I'm after is a display of a score that counts up as it moves along a score bar.
coob
My fault (see above edit), what I originally intended works, I was just being stupid. Thanks for the in depth answer anyway.
coob