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/