【发布时间】:2020-08-21 08:17:22
【问题描述】:
我有 2 个视图控制器:
- VC1
- VC2
(VC2 呈现在 VC1 之上)
每当我在 VC2 中时,我都需要提前知道 VC1 的子视图的 (CGPoint) 位置,以便我可以应用动画来关闭 VC2。
我考虑过实现委托和协议,这就是我所做的:
protocol PreviewCapturedViewControllerDelegate {
func retrieveIconPosition() -> CGPoint
func goToProfilePosition()
}
但我实际上不知道如何使用此协议检索视图的位置。
【问题讨论】:
-
获取VC1子视图相对于VC2的坐标,可以参考这个Get Position of UIView within entire UIWindow。
-
@CosmosMan 谢谢解答,问题是VC2不是VC1的子视图,其实是在上面呈现的
标签: swift delegates protocols cgpoint