Search code examples
iosswiftgoogle-mapsswift5gmsmapview

swift GMSMap markerInfoWindow show by animation


i want to show my markInfoWindow when i tap the marker from red to blue

i tried this

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
    
    let windowInfoView: UIView = {
        let view = UIView(frame: CGRect.init(x: 0, y: 0, width: 130, height: 55))
        view.backgroundColor = UIColor.white
        view.layer.cornerRadius = view.frame.height/3
        
        return view
    }()
    

    let anim : CABasicAnimation = CABasicAnimation(keyPath: "backgroundColor")
    anim.fromValue = UIColor.yellow.cgColor
    anim.toValue = UIColor.red.cgColor
    anim.duration = 2.0

    windowInfoView.layer.add(anim, forKey: "backgroundColor")
    
    return windowInfoView

but when i tap marker, it show yellow window direct, didn't show from yellow to red in 2 sec thanks


Solution

  • i solved this problem

    i created a custom view and add view in delegate

    func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
        
        self.view.addSubview(self.infoWindow)
        
        UIView.transition(with: self.view, duration: 1, options: [.transitionCrossDissolve], animations: {
            self.infoWindow.alpha = 1
        }, completion: nil)
        
        return false
    }
    

    can't custom view in markerInfoWindow because it return a UIView.