开发者

I want to create a spinner like Dinner Spinner

I want to create a spinner like Dinner Spinner.

开发者_运维知识库I am approximately there by using UIPicker. but thing which I cant achieve is after rotating on button press, stopping the spinner animation softly.


You cannot have deceleration effect in UIPickerView. Looking at the dinner spinner app, i think they have used scrollview there.

UPDATE:

As far as scroll view is concerned, you need to play with

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated

and

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated

for table view.

But this approach works if you have enough items in the scroll view to show for enough spinning time. I mean, what if you reach the end item and you still want to spin?

Here, you need to do all things manually and it isn't hard. I have made slot machine application where i made the custom spinner.

And it works something like this…

You could have items A, B, C, D and E from which B, C and D are visible. You keep shifting each of them left (or right) firing NSTimer. And when the leftmost item goes out of bounds, put it to the extreme right. This will give an illusion that the items are circular.

And after some time has elapsed you can get the decelerating effect by reducing the shifting (acceleration) by arithmetic progression or geometric progression.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜