Creating a scrolling counter
I would like to create a scrollin开发者_运维知识库g counter and I'm wondering on how to implement this. Should I use for each digit a separate view and animate the view upwards or downwards to create the scrolling effect?
Or is there a better way to do this ?
(source: macromedia.com)You could make a vertical strip of numbers 0 through 9 and then animate changing the strip's frame's origin.
To get a "seamless" effect, "glue" three strips together vertically and animate changing their origins.
If your counter is increasing and animation causes the bottommost strip to move outside of bounds, add another strip to the top —- and vice versa, if the counter is decreasing.
Since there are only 10 possible transitions, you could pre-render them and have more detailed animation. Otherwise, what you described seems appropriate. Just thought I'd suggest it.
Should I use for each digit a separate view and animate the view upwards or downwards to create the scrolling effect?
Probably your best bet. At very least, this strategy should allow you to effectively manage the complexity involved. The "direction" you animate in is simply a stylistic decision.
精彩评论