Tillson
Tillson

Reputation: 530

MapKit Animations

I'm trying to use UIView animations for animating the camera in MapKit, but it seems to be skipping to the end.

MKMapCamera *cam = [[MKMapCamera alloc] init];
cam.centerCoordinate = location.coordinate;
cam.altitude = 10E5;
[UIView animateKeyframesWithDuration:1.0 delay:1 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
    [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{
        mapView.camera = cam;
    }];
    [UIView addKeyframeWithRelativeStartTime:10.0 relativeDuration:0.5 animations:^{
        mapView.camera.altitude = 10E10;

    }];

} completion:nil];

Upvotes: 2

Views: 662

Answers (1)

Ben Pious
Ben Pious

Reputation: 4805

From the docs: "Assigning a new camera to this property updates the map immediately and without animating the change. If you want to animate changes in camera position, use the setCamera:animated: method instead."

You could try setCamera:animated:, but getting the time it takes for the first animation to complete might not be possible.

Upvotes: 4

Related Questions