[英]How do I get the frame of a subview in the ToViewController during animateTransition:?
[英]Custom ViewController Transitions: Get ToViewController's Subview's Frame
以下是我的问题的说明:
我在ViewControllers A和B中有StarImageView,它在ViewController中显示相同的图像但彼此具有不同的帧。
当点击 ViewController A中的StarImageView时,应用程序将新的视图控制器推入导航控制器堆栈,同时在ViewController B中动画到其最终帧。
这种行为就像iPhone照片应用程序中的过渡一样。
我使用ViewController A中的初始StarImageView框架和图像初始化animator对象中的临时UIImageView,并通过硬编码rect CGRectMake(0, 60+44, containerView.bounds.size.width, containerView.bounds.size.width)
其设置为最终帧。 CGRectMake(0, 60+44, containerView.bounds.size.width, containerView.bounds.size.width)
(ViewController B中StarImageView的框架),并从动画完成块中的superview中删除临时UIImageView。
该项目是在故事板中创建的,启用了autolayout。 我想要做的是在转换期间在ViewController B中获取StarImageView的帧,而不是像上面那样对其进行硬编码。 由于ViewContorller生命周期,我无法在animator对象中引用ViewController B中的任何子视图,因为它们尚未初始化。
对于这种情况,还有其他解决方案或最佳实践吗? 提前致谢!
[toViewController.view layoutIfNeeded];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.