简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM