views:

204

answers:

3

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

+1  A: 

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.

Eric Mickelsen
+1  A: 

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.

Alex Reynolds
You could then get the nice 3-D effect by overlaying a static translucent layer with dark gradients at the top and bottom and a "shine" gradient near the top. If you pull apart the elements of a UIPickerView, I think that's what it does.
Brad Larson
Yep. Just throw a layer or two to mask out the numerals. It would be ideal to think about the portrait and landscape cases.
Alex Reynolds
This seems to me the most appropriate method, but can you explain on how to keep the views that are out of bounds from displaying? I tried to create a rectangular view for the counter and added each strip as a subview, but apparently the strips do keep appearing fully instead as I would expect only the part that is in bounds of the rectangular shape ?
Oysio
A: 

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.

rpj