Using convertPoint to get the relative position inside a parent UIView

后端 未结 5 1428
臣服心动
臣服心动 2020-12-07 13:12

I\'ve looked at a dozen SO questions on this topic, and none of the answers have worked for me. Maybe this will help get me back on the right path.

Imagine this set

5条回答
  •  旧巷少年郎
    2020-12-07 13:46

    Here is Swift 3 update of @Pablo's answer, which off course worked great in my case.

    if let window = UIApplication.shared.keyWindow {
        parent.convert(child.frame.origin, to: window)
    }
    

提交回复
热议问题