I’m trying to make a drag and drop exercise where I have to drag a yellow box to the correct term on the other side. It should look like this at the end.
I have an action function that moves the yellow box and when it intersects in any way it sticks.
@IBAction func dragGSV(_ sender: UIPanGestureRecognizer) {
let theView = sender.view!
let translation = sender.translation(in: content)
switch sender.state {
case .began, .changed:
theView.center = CGPoint(x: (theView.center.x) + translation.x, y: (theView.center.y) + translation.y)
sender.setTranslation(CGPoint.zero, in: view)
case .ended:
if theView.frame.intersects(tot.frame) {
theView.isUserInteractionEnabled = false
}
default:
break
}
}
I want theView which is my yellow box to be able to intersect the red one but only on the left side of the red one. How can I do that?