iOS GoogleMaps SDK - animateToCameraPosition animation finished handler?

后端 未结 5 1889
离开以前
离开以前 2021-02-19 14:54

Currently I am using the GoogleMaps SDK for iOS for various operations. When calling

[self.googleMapsView animateToCameraPosition:[GMSCameraPosition 
                  


        
5条回答
  •  感动是毒
    2021-02-19 15:23

    I came across the issue of google's animation methods lacking completion handlers recently.
    The best solution I've found so far is to attach my own completion handler via CATransation API.

    private func attachCompletionHandlerToGoogleAnimations(@noescape animations: () -> Void, #completion: (() -> Void)!) {
        CATransaction.begin()
        CATransaction.setCompletionBlock(completion)
        animations()
        CATransaction.commit()
    }
    

    Example usage:

    attachCompletionHandlerToGoogleAnimations({
        googleMapView.animateToLocation(coordinate)
    }) {
        println("camera moved to location \(coordinate)")
    }
    

提交回复
热议问题