What I would like to make is a bar with growing animation and the text(number) also growing with the value of bar length. It looks like:
The bar should be growing horizontally and the text with number should grow too. And the user may be want to play the animation again by tap "Replay".
After read apple programming guide and some great tutorials, I have a general idea. With Quartz2d, I could draw the bar and also the vertical line, and also the text as well. But Quartz2d does not have animation effect. With Core Animation, I could change the shape of the bar by time and specified properties value. Am I right on this?
So I guess what I want is combine Quartz2d and Core Animation, draw the bar with Quartz2d first and then use CA to animate it? Is it the correct way to do this? Or if any other light-weight solution available, I will greatly appreciate.
PS: I'm very new to iPhone drawing, as far as I know, the lightest way to do animation is by UIView animation, and the lighter one is by CALayer animation. And the whole drawing work is by Quartz2d, am I correct? It's kind of confusing even after I read this post. But to be practical, I do not (or not able to) get too conceptual about the whole graphic system. But I will definitely keep digging after write some actual code about this.
So, right now, I just need to know if this is the best way to realize this animation effect.
Thanks guys :)
I would use something like what I've written below. It'll grow your frame over the course of 1.5 seconds (of course, you can change the duration). I'm not sure what kind of object you're using for your shape. You can just use something like a
UIView
and set thebackgroundColor
to whatever you want.Wasn't sure what exactly you meant by 'growing your text' (incrementing it or increasing font size), so I've given an example that'll keep your text at the end (right) of your horizontal bar). This should give a good starting point for experimenting with
UIView
animations.Incrementing Label Update
You'll need to use an
NSTimer
to increment your label. Try this code out.in your .h
in your .m
Use this to start your counting. You'll probably want to put this just before your
UIView
animations.This is the selector the timer calls each time it fires (every 0.03 seconds):