As shown on this picture: Picture I have a GoogleMaps view in the background and a yellow view in the foreground. I need catch tap gestures on the yellow view and every other gestures (mainly pinch) forward to the GoogleMaps view.
I tried to add the yellow view as a child-Subview of the GoogleMaps View (I found this advice here: https://stackoverflow.com/a/10594097/8851253):
class ViewController: UIViewController {
@IBOutlet weak var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
let uiView = UIView(frame: CGRect(x: 100, y: 100, width: 150, height: 200))
uiView.backgroundColor = UIColor.yellow
// gesture recognizer
let clickUITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.clickAction(_:)))
uiView.addGestureRecognizer(clickUITapGestureRecognizer)
self.mapView.addSubview(uiView)
}
@IBAction func clickAction(_ sender: Any) {
print ("tap")
}
}
And it would work perfectly if it were normal views, but since it is GMSMapView class, something gets wrong and "clickAction" is not called.
(GMSMapView was assigned to the view in the interface builder)
Here is the project: https://gitlab.com/Cerny/googleMapsForwarding
Any idea how to solve it, please?