简体   繁体   English

在 iOS 中创建基于卡片的 UI

[英]Creating a card based UI in iOS

Im trying to do app with a card based ui, kind of like Jelly.我正在尝试使用基于卡片的 ui 来制作应用程序,有点像 Jelly。 I was wondering the how this would be done.我想知道这将如何完成。 Im thinking by using a collection view but Im not sure.我正在考虑使用集合视图,但我不确定。 Are there any open source libraries that would make it easier to do this?是否有任何开源库可以更轻松地做到这一点? Thanks.谢谢。

在此处输入图片说明

You're probably not going to be able to accomplish this using out-of-the-box components. 您可能无法使用开箱即用的组件来完成此任务。 I don't think UICollectionView is going to get you very far. 我不认为 UICollectionView会让你走得很远。 You will almost certainly need to roll your own. 您几乎肯定需要自己动手。

I would start by creating a View Controller class for the "cards", instantiate a few of them, add the views as subviews to the main view, and get to the point where you can comfortably push these cards around with your fingers.我将首先为“卡片”创建一个视图控制器类,实例化其中的一些,将视图作为子视图添加到主视图,然后你可以用手指轻松地推动这些卡片。 You will want to read up on animating UIViews , and UIGestureRecognizers .您将需要阅读动画UIViewsUIGestureRecognizers Make sure the momentum is right.确保势头是正确的。 Apps like this really really demand highly-tuned physics, otherwise they'll feel awkward.像这样的应用程序真的需要高度调整物理,否则他们会感到尴尬。

Once you get to the point where your cards are happily zipping around the screen, it's just a matter of getting them to "sink" into a couple pre-defined positions (focused front-and-center, and resting in a stack down below).一旦你的卡片愉快地在屏幕上滑动,只需让它们“下沉”到几个预先定义的位置(聚焦在前面和中间,并在下面的堆栈中休息) . You would probably also want to give your view controllers some sort of state that indicates whether they're "active", or not.您可能还想为您的视图控制器提供某种状态来指示它们是否“活动”。

Easier said than done, obviously.说起来容易做起来难,显然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM