How to find out what view a touch event ended at?

后端 未结 5 1551
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 00:16

I wish to drag a UIImage on to one of several UIButtons and have it repositioned based on which button I drag it to.

The problem I\'ve ran in to is that UITouch only

5条回答
  •  情书的邮戳
    2020-12-06 01:04

    swift 4:

    override func touchesEnded(_ touches: Set, with event: UIEvent?) {

        if let touch = touches.first{
            let location = touch.location(in: self.view)
            let v = touch.view
    

    // go on.. }

    }
    

提交回复
热议问题