Hit test helps us to understand if a view can be interactive with user.
When the touch event is performed by the user, the system calls this function to trigger the touch or gesture recognizer an returns the frontmost view interacted with.
If we have multiple subviews in a view, how to perform a hit test on views?
Let’s say we want to interact with the purple one and not the green one.
isUserInteractionEnabled = false
this method cannot be used for green view because then purple view will be affected by it. So the solution is, overriding hit test on foremost view (green view) like this: