UIPickerView 动画

发布于 2024-09-08 04:13:16 字数 120 浏览 3 评论 0原文

您好,我正在开发一款使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

星光不落少年眉 2024-09-15 04:13:16

坦白时间:当我发布另一个答案时,我从未使用过 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.

不语却知心 2024-09-15 04:13:16

您想要的方法是

- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated

所有其他方法都失败,您可以随时尝试查看文档。 http://developer.apple.com/ iphone/library/documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html

The method you want is

- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文