简体   繁体   English

如何在iPhone应用程序中为此自定义视图转换设置动画?

[英]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.

相关问题 如何在iPhone应用程序中使用2选择器视图? - How can i use 2 picker view in my iPhone app? 如何向我的 iphone 应用程序添加额外的“视图”? - How can I add an additional "view" to my iphone app? 如何设置我的视图大小调整动画? - How can I animate my view resizing? 如何在iPhone 5 Web应用程序上显示我的自定义CSS? - How can I show my custom css on the iPhone 5 web app? 如何在简单的View iPhone App上动画查看交换? - How to animate View swap on simple View iPhone App? 如何在我自己的自定义视图中重现iPhone UIScrollView的轻弹滚动行为? - How can I reproduce the flick-to-scroll behavior of the iPhone UIScrollView in my own custom view? 我可以在我的iPhone应用程序中为UIToolBar提供自定义背景吗? - Can I give a UIToolBar a custom background in my iPhone app? 如何在不引入View或Tab控制器的情况下将核心位置数据集成到我的空白iPhone App中? - How can I integrate core location data to my blank iPhone App without introducing View or tab controller? 如何在越狱的iPhone上测试iPhone应用程序? - How can I test an iPhone app on my iPhone that is Jailbroken? 如何在iPhone应用程序的UI中添加自定义视图? - How do I add a custom view to iPhone app's UI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM