如何减慢MKMapCamera的运动? [英] How to slow MKMapCamera movement?

查看:95
本文介绍了如何减慢MKMapCamera的运动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS进行编码.

I am coding in iOS.

我有一个NSArray,其中包含一些MKMapCameras.我想一个接一个地显示数组中的MKMapCameras.

I have an NSArray, which contains a few MKMapCameras. I want to display MKMapCameras from the array one after another.

我放置了while循环并使用了[self.mapView setCamera:nextCamera animated:YES];

I put a while loop and used [self.mapView setCamera:nextCamera animated:YES];

但是,这仅显示第一个和最后一个视图.两者之间的一切都进行得太快了.

However, this is only showing the first and the last views. Everything in between is going too fast.

我想放慢每台摄像机的移动速度.有没有一种方法可以使用CATransaction或其他任何动画技巧来实现.如果是这样,您能给我看看示例代码吗?

I want to slow down the movement of each camera. Is there a way to achieve it using CATransaction or using any other animation tricks. If so, could you please show me an example code?

想提供更新...我尝试了下面的代码.但这没用...像我前面提到的那样,相机运动很快.

Want to give an update... I tried below code. But it isn't working... Camera movements are fast as I mentioned earlier.

[CATransaction begin];
[CATransaction setAnimationDuration:5.5];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[CATransaction setCompletionBlock:^{
    [self.mapView setCamera:nextCamera animated:YES];
}];
[CATransaction commit];

推荐答案

摆弄了几个小时后,我想出了一种使其工作的方法.想与所有人共享相同的东西...

After fiddling with it a few hours, I figured out a way to make it work. Thought of sharing the same with everyone...

我做了两个更改.我用UIView的动画替换了CATransaction.我还删除了Camera的默认动画设置,该设置与UIView的动画冲突.

I made two changes. I replaced CATransaction with UIView's animation. I also removed Camera's default animation settings, which was conflicting with UIView's animation.

下面是代码.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:2.5];
self.mapView.camera = nextCamera;
[UIView commitAnimations];

这篇关于如何减慢MKMapCamera的运动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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