Col*_*ips 26 animation ios google-maps-sdk-ios
Google Maps for iOS的文档指出:
调用几种方法之一,允许您为移动到新位置的相机设置动画.您可以使用CoreAnimation控制动画的持续时间.
对于我的生活,我无法弄清楚如何控制动画的持续时间.我尝试过使用UIView动画,例如:
[UIView animateWithDuration: 5 animations:^{
GMSCameraPosition *camera = [self newCamera];
self.mapView.camera = camera;
} completion:^(BOOL finished) {
}];
Run Code Online (Sandbox Code Playgroud)
我在CoreAnimation中查看过CALayer动画.但是,我不知道如何将图层动画应用于地图视图.
有人能指出我正确的方向吗?
Col*_*ips 40
我找到了答案......您可以通过在CATransaction中包装一个animate*方法来控制动画持续时间,如下所示:
[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];
Run Code Online (Sandbox Code Playgroud)
len*_*ooh 13
对于Swift 3.0:
CATransaction.begin()
CATransaction.setValue(1.5, forKey: kCATransactionAnimationDuration)
// your camera code goes here, example:
// mapView.animate(with: update)
CATransaction.commit()
Run Code Online (Sandbox Code Playgroud)
值越大(在这种情况下为1.5),动画越慢.
Swift 2.0
CATransaction.begin()
CATransaction.setValue(NSNumber(float: 1.0), forKey: kCATransactionAnimationDuration)
// change the camera, set the zoom, whatever. Just make sure to call the animate* method.
CATransaction.commit()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8430 次 |
最近记录: |