简体   繁体   English

(iOS)如何在两个ViewController之间的过渡中为UI元素(例如标签和图像)的过渡设置动画?

[英](iOS) How can i animate the traslation of UI elements, like labels and images in the transition between two viewcontrollers?

I'm working on animated transitions between VC. 我正在研究VC之间的动画过渡。 I have a collectionVC and a DetailVC. 我有一个collectionVC和一个DetailVC。 The collectionVC has custom type cells and there are some common UI items like labels and images between both VC. collectionVC具有自定义类型的单元格,并且两个VC之间有一些常见的UI项,例如标签和图像。 The idea is that when a cell is tapped, it goes fullscreen, and those common items should relocate (traslate) to the their initial state on the DetailVC . 这个想法是,当点击一个单元格时,它将进入全屏状态,并且那些常见项目应在DetailVC上重新定位(平移)为其初始状态。

ie, if "someRedLabel" it's in the right bottom corner on the detailVC , when i tap the cell in the collectionVC , "someRedLabel" should traslates from where it is at the moment, to the right bottom corner, as the cell expands to fullscreen. 即,如果“ someRedLabel”位于detailVC的右下角 ,则当我点击collectionVC中的单元格时,“ someRedLabel”应从当前位置平移到右下角,随着单元格扩展到全屏。

I'm using the transitiondelegate, setting by hand frame to frame of all the different UI elements, from the current context to the DetailVC, it almost do what i want but always something fails (some does not animate, some does not relocate) and im thinking that maybe the approach it isn't the correct 我正在使用transitiondelegate,手动设置所有不同UI元素的框架,从当前上下文到DetailVC,它几乎可以完成我想要的操作,但总是会失败(有些没有动画,有些没有重新定位),我在想,也许这是不正确的方法

I would like to know what is the correct approach to do this. 我想知道什么是正确的方法

Thanks. 谢谢。

My suggestion to this is making a copy of your "redlabel", then add it to your second VC's view. 我的建议是制作“ redlabel”的副本,然后将其添加到第二个VC的视图中。 If you don't know where to add it in the second view, you can use pointConvertToView or RectConvertToView methods. 如果您不知道在第二个视图中的添加位置,则可以使用pointConvertToView或RectConvertToView方法。

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

相关问题 如何使用 iOS swift hero 框架在两个视图控制器之间进行转换? - How to use iOS swift hero framework for transition between two viewcontrollers? 如何为两个模态视图控制器之间的过渡设置动画? - How can I animate the transition between two modal view controllers? SwiftUI:如何使用延迟为两个图像之间的过渡设置动画? - SwiftUI: how to animate transition between two Images using a delay? 如何在两个子视图 iOS 之间创建过渡? - How can I create a transition between two subview iOS? 在两个视图控制器之间执行代码/触发UI元素 - Executing code/triggering UI Elements between two viewcontrollers 如何在Cocoa Touch中的任何两个ViewController之间过渡? - How to transition between any two ViewControllers in Cocoa Touch? 像Instagram这样的ViewControllers之间的动画UITextView - Animate UITextView between ViewControllers like Instagram does 在同一屏幕上的子viewController之间的iOS转换 - IOS Transition between child viewControllers on same screen 由rootView控制器呈现的两个viewController之间的过渡 - Transition between two viewControllers presented by rootView controller 如何在两个 PNG 图像之间为 UIButton 设置动画? - How do I animate a UIButton between two PNG images?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM