Search code examples
iphonecocoa-touchcore-animation

Creating a scrolling counter


I would like to create a scrolling 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 ?
alt text
(source: macromedia.com)


Solution

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