在Google Maps for iOS中控制动画持续时间 [英] Controlling Animation Duration in Google Maps for iOS

查看:103
本文介绍了在Google Maps for iOS中控制动画持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

适用于iOS版Google地图的文档说明:

The documentation for Google Maps for iOS states that:


调用几种方法中的一种,可让您为移动到相机的相机设置动画新的位置。您可以使用CoreAnimation控制动画的持续时间。

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动画,例如:

For the life of me, I can't figure out how to control the animation duration. I have tried using UIView animations, like:

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

我看过CoreAnimation中的CALayer动画。但是,我不知道如何将图层动画应用到地图视图。

And I have looked at CALayer animations in CoreAnimation. However, I don't know how you would apply a layer animation to the map view.

有人可以指出我正确的方向吗?

Can someone point me in the right direction please?

推荐答案

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

I found the answer ... you can control the animation duration by wrapping one of the animate* methods in a CATransaction, like this:

   [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];

这篇关于在Google Maps for iOS中控制动画持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆