点击顶部视图时如何检测底部视图的触摸位置

How to detect touch location of the bottomView when the topView is tapped

我有四个 UIViews(topViews) 作为子视图添加到 mainView。我想创建一个从 topViews 到端点的 bezierPath。为此,我需要获取 topView 相对于 bottomView 的位置。

我希望 bottomView 不检测任何触摸,我只希望 topView 获得触摸,但在 return 中给出它们相对于 bottomView 的位置。

这怎么可能?我目前正在使用 touchesBegan,它只是从整个底视图给我位置。

您可以使用topView.convert(point, to: bottomView)方法将从顶部视图坐标系检测到的点转换为底部视图坐标系。