I have a:
myViewController
- subclass of UIViewController
myFirstView
- subclass of UIView
mySecondView
- subclass of UIView
Inside myFirstView
I added a UIView
object called myLittleView
as subview to myFirstView
's window (UIWindow) and added a
UIPanGestureRecognizer` to it so the user can drag the view in the window.
I've also added a CGRect
object inside myFirstView
called secondViewFrame
that's contains the frame of the mySecondView
object' frame.
I've added myFirstView
and mySecondView
object as subview to myViewController
's view.
Now I want to check if myLittleView
is ontop of mySecondView
, I've tried to add this code to the UIPanGestureRecognizer
's action but it gave the wrong result:
let pointInViewController = sender.translationInView(self.superview)
if self.secondViewFrame!.contains(pointInViewController) {
print("Inside")
}
Any idea how can I make it work?
Thanks!