[英]How can I animate this custom view transition in my iPhone app?
This is a tricky question to explain, but basically I have an app with a home screen with a bunch of circular icons on it. 这是一个棘手的问题需要解释,但基本上我有一个带有主屏幕的应用程序,上面有一堆圆形图标。 When the user taps on an icon, it pushes a table view onto the navigation stack.
当用户点击图标时,它会将表格视图推送到导航堆栈。 When an icon is tapped on the home screen, I want the tapped icon to stay on top of the table view as it scrolls in, and then drop onto the table view in the cell that represents it.
当在主屏幕上点击图标时,我希望点击的图标在滚动时保持在表格视图的顶部,然后放到表示它的单元格中的表格视图上。 All the other icons, however, should stay below the incoming table view, like normal.
但是,所有其他图标应保持在传入表视图下方,就像正常情况一样。 Here's a quick diagram I whipped up...
这是一个我掀起的快速图表......
I'm about to begin researching this, I just wanted to quickly post this question in case anyone has some ideas about how I can approach this. 我即将开始研究这个问题,我只是想快速发布这个问题,万一有人对我如何处理这个问题有一些想法。 Thanks so much for your wisdom!
非常感谢你的智慧!
Oh thats soo easy!!! 哦,太容易了!
I'll try to explain my solution: 我会尝试解释我的解决方案:
You need two sets of icons. 你需要两套图标。
One set lays on Home View, second is exact location, but as a subview on main window (by default - hidden) 一组放在Home View上,第二组是精确位置,但是作为主窗口上的子视图(默认情况下 - 隐藏)
Once You select a button, and want to push a list - You un-hide corresponding window subview icon, and with delay - animate / shrink it to tableView corresponding location. 一旦你选择了一个按钮,并想要推送一个列表 - 你取消隐藏相应的窗口子视图图标,并有延迟 - 动画/缩小它到tableView对应的位置。
Once animation is finished - hide icon (instant hide will not be noticeable, as this icon will be positioned/scaled to precisely reassemble icon in tableview), and move it to default position/scale (still hidden). 动画完成后 - 隐藏图标(即时隐藏不会引人注意,因为此图标将被定位/缩放以精确地重新组合tableview中的图标),并将其移动到默认位置/比例(仍然隐藏)。
That's it. 而已。
This is pretty simple, and can be done without adding second instances of your buttons. 这非常简单,无需添加按钮的第二个实例即可完成。 You'll use the view hierarchies z-index for this.
您将使用视图层次结构z-index来实现此目的。
When you add the table view as a subview of the main view don't use addSubview
, use: 当您将表视图添加为主视图的子视图时,请不要使用
addSubview
,请使用:
[self.view insertSubview:table belowSubview:button];
Button^ will represent the button that you want to stay on top, and for your other buttons, you just have to make sure that they are lower on the stack. 按钮^将代表您想要保持在顶部的按钮,而对于其他按钮,您只需确保它们在堆叠中较低。 This way, when the table flies in, it can keep going past the button but the button will stay above it.
这样,当桌子飞进来时,它可以继续经过按钮,但按钮将保持在它上面。
You can also use: 您还可以使用:
[self.view insertSubview:table atIndex:5];
On all of these buttons and the table to have total control over each objects z-index. 在所有这些按钮和表上,可以完全控制每个对象的z-index。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.