iPhone 上的滑下视图
我想创建一个向下滑动的动画,如链接中的图像所示。当我按“上一页”时,我希望它向下滑动到屏幕中央。我不太确定如何实施。任何建议都会非常方便。
I want to create a slide-down animation, like in the image in the link. When I press on "Previous", I want it to slide down to the center of the screen. I am not really sure how to implement that. Any suggestion would be really handy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这看起来像一个 UITableView。您可以使用“上一步”按钮放置自定义单元格,该单元格将加载上面的新数据,然后调用
scrollToRowAtIndexPath:atScrollPosition:animated:
函数来执行动画。This looks like a UITableView. You can place a custom cell with the button Previous, which will load the new data above and then call the
scrollToRowAtIndexPath:atScrollPosition:animated:
function to perform the animation.整个事情很可能是某种
UIScrollView
(UITableView
也是滚动视图)。按下按钮时,使用setContentOffset:animated:
或scrollRectToVisible:animated:
执行以下操作滚动。 “魔力”在于计算正确的偏移量或矩形。我建议使用setContentOffset:animated:
。它应该大致像这样工作:The whole thing is pretty likely a
UIScrollView
of some sort (UITableView
s are scroll views as well). When the buttons is pressed, either usesetContentOffset:animated:
orscrollRectToVisible:animated:
to do the scrolling. The "magic" is just in calculating the correct offset or rect. I'd suggest going withsetContentOffset:animated:
. It should work roughly like this: