Fry
Fry

Reputation: 922

Slow down UIView animation within Animation

i have simple UIView animation block which animates the origin of 2 views. I have a Button on a special position placed on a mapview view. so when i'd like to animate the center of the map and move the pin with the map, the map moves faster than the button. Is there a way, to speed up the animation of the button or to slow down the animation of the map? At the moment it looks like the map moves and the button jumps to his end position.

CGPoint newCenter = mapView.center;
newCenter.x -= 1;
newCenter.y -= (button.frame.size.height/2)


[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationCurveEaseIn animations:^{

     CGPoint screenPoint = fakePin.frame.origin;
     screenPoint.x -= 5;
     screenPoint.y += button.frame.size.height-4;

     mapView.mapCoord = [mapView.map convertPoint:screenPoint toCoordinateFromView:self.view];
    self.mapView.map.centerCoordinate = mapView.mapCoord;
     [button setCenter:newCenter];
}];

Any Ideas?

Upvotes: 2

Views: 870

Answers (2)

Fry
Fry

Reputation: 922

i just figured out, that the Problem was that my setCenter: was called without animating, somehow it worked with the Google Maps in ios5 (animating itself but not in ios6=

No it works!!

Upvotes: 0

Fábio Oliveira
Fábio Oliveira

Reputation: 2346

Why not show the button as an annotation? Then it would move along the map.

Still, try to animate the property frame on the button instead of center. You'll need to do the calculations on your own but I think that may be the problem.

Upvotes: 1

Related Questions