UIPickerView 动画
您好,我正在开发一款使用 pickerview 的 iPhone 应用程序,摇动应用程序后会随机选择一个选项。一切都运行良好,但我想知道是否有任何方法可以像 Urban Spoon 那样为 UIPIckerView 制作动画。
Hi I am developing an iPhone app which uses pickerview, Upon shaking app selects one random choice. Everything works well but I was wondering is there any way to animate the UIPIckerView as Urban Spoon has done it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
坦白时间:当我发布另一个答案时,我从未使用过 Urban Spoon,我认为你很懒。我不会覆盖我之前的答案,因为这样粗鲁的回应值得得到反对票。
如果我要制作像城市勺子的拾取轮上的动画,我可能会使用 UIImageView 的翻页式动画,如下所示: http://iosdevelopertips.com/graphics/animated-gif-animated-images-iphone-style.html
简短版本:属性
UIImageView.animationImages
可以使用 UIImages 的 NSArray 来加载。您可以设置.animationRepeatCount
和.animationDuration
等属性。然后 [UIImageView startAnimating] 会让那个东西开始动画。我猜 Urban Spoon 会用“快速滚动”图像集来执行此操作,然后将其替换为“中速滚动”图像集,然后完全摆脱 UIImageView 并将其替换为 UIPickerView以动画方式到达预先选择的随机位置。
Confession time: when I posted the other answer, I hadn't ever used Urban Spoon, and I assumed you were being lazy. I'm not overwriting my earlier answer, because such a rude response deserves the downvotes it got.
If I were going to make an animation like the ones on urban spoon's picker wheels, I'd probably use UIImageView's flipbook-style animation, as demonstrated here: http://iosdevelopertips.com/graphics/animated-gif-animated-images-iphone-style.html
Short version: the property
UIImageView.animationImages
can be loaded with an NSArray of UIImages. You can set properties like.animationRepeatCount
and.animationDuration
. And then[UIImageView startAnimating]
will make that thing start animating.I'd guess Urban Spoon does that for a second with the "fast rolling" set of images, replaces that with the "medium-speed rolling" set of images, and then gets rid of the UIImageView entirely and replaces it with a UIPickerView that's animating its way to a pre-selected random position.
您想要的方法是
所有其他方法都失败,您可以随时尝试查看文档。 http://developer.apple.com/ iphone/library/documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html
The method you want is
All else fails, you could always try looking at the docs. http://developer.apple.com/iphone/library/documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html