在iOS中,实现滑动“抽屉”的最佳方式是什么?

发布于 2025-01-04 12:50:24 字数 255 浏览 4 评论 0原文

我不确定“抽屉”是否是正确的术语,但我想了解如何实现从元素下方滑出并将视图上的其他内容向下推的对话框。

很好的例子是 Apple 的天气应用程序(点击一天后会显示详细的天气预报信息)和 Tapbots 的 Tweetbot(单击推文时显示推文级别控件

感谢您提供任何信息!

I'm not sure if "drawer" is the right term, but I'm wanting to find out how to implement dialogs that slide out from under an element and push the other content on the view down.

Good examples are Apple's Weather app, which reveals detailed forecast info when a day is clicked, and Tapbots' Tweetbot, which reveals Tweet-level controls when a tweet is clicked.

Thanks for any info!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

帅气称霸 2025-01-11 12:50:24

一种选择:

为“抽屉”创建一个视图。您可以将其放置在另一个视图后面,或者放置在屏幕外。当用户点击正确的位置或以其他方式导致抽屉“打开”时,将视图移动到其“打开”位置。如果抽屉相对于屏幕垂直打开,您可能需要将其向上或向下滑动抽屉的高度;如果水平打开,请将其向左或向右滑动一个抽屉宽度。使用核心动画可以轻松制作位置变化的动画,并使其看起来像是抽屉正在滑开。 UIViewAnimationOptionCurveEaseInOut 动画曲线将使此看起来不错。显然,将抽屉向另一个方向移动即可再次关闭。

One option:

Create a view for the "drawer". You can place it behind another view, or just off screen. When the user taps in the right spot or otherwise causes the drawer to "open," move the view to it's "open" position. If the drawer is opening vertically with respect to the screen, you'll probably want to slide the it up or down by the height of the drawer; if it's opening horizontally, slide it left or right by one drawer width. Use Core Animation to make it easy to animate the change in position and make it look like the drawer is sliding open. The UIViewAnimationOptionCurveEaseInOut animation curve will make this look nice. Obviously, move the drawer in the other direction to close again.

向地狱狂奔 2025-01-11 12:50:24

查看此答案。我已经使用过它并且效果非常好。基本上,您要做的就是当用户点击一行时向表视图添加新行。

Check out this answer. I've used it and it works perfectly. Basically what you're doing is adding a new row to the table view when the user taps on a row.

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