ios - 在 iOS 版 Google map 中控制动画持续时间

标签 ios animation google-maps-sdk-ios

iOS 版 Google map 的文档指出:

Call one of several methods that allow you to animate the camera moving to a new location. You can control the duration of the animation with CoreAnimation.

对于我的生活,我无法弄清楚如何控制动画持续时间。我试过使用 UIView 动画,例如:

    [UIView animateWithDuration: 5 animations:^{
         GMSCameraPosition *camera = [self newCamera];
        self.mapView.camera = camera;
    } completion:^(BOOL finished) {
    }];

我还研究了 CoreAnimation 中的 CALayer 动画。但是,我不知道如何将图层动画应用到 map View 。

有人能给我指出正确的方向吗?

最佳答案

我找到了答案...您可以通过将其中一个 animate* 方法包装在 CATransaction 中来控制动画持续时间,如下所示:

   [CATransaction begin];
   [CATransaction setValue:[NSNumber numberWithFloat: 1.0f] forKey:kCATransactionAnimationDuration];
   // change the camera, set the zoom, whatever.  Just make sure to call the animate* method.
   [self.mapView animateToCameraPosition: [self newCamera]];
   [CATransaction commit];

关于ios - 在 iOS 版 Google map 中控制动画持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15662148/

相关文章:

javascript - 为什么 html canvas 动画会为每个新矩形渲染一个临时间隙?

ios - 当有人使用 Google map 路线时在我的应用程序中获取路线

objective-c - 如何正确初始化 RestKit 的 objectStore 以使用文档以外的目录

ios - 为什么创建大量 SKNode 需要这么长时间

ios - 如何阻止 subview 的 didSelectRowAtIndexPath?

ios - 创建开发证书 iOS

wpf - 多个目标名称的相同动画

python - 带颜色编码的动画散点图失去颜色(Python/Plotly)

ios - 如何实现 iOS Google Maps SDK

iphone - 在 iPhone 的谷歌地图中添加像 UISlider 或 UIButtom 这样的 subview