Question

I have a translate animation, moving my button from A to B.

That route looks like this:

1) Button slowly accelerates 2) At the middle of animation gets to the peak of it's speed 3) Slows down as it approaches the end

This is my code

[UIView animateWithDuration:speed
                      delay:delay
                    options:UIViewAnimationOptionAllowUserInteraction
                 animations:^(void){
                     [UIView setAnimationRepeatCount:5];
                     cloud.frame = (CGRectMake(cloud.frame.origin.x,   
cloud.frame.origin.y+900, cloud.frame.size.width, cloud.frame.size.height));

                 }completion:nil];

I want my animation to have a same speed all the time.

How can I achieve this?

Was it helpful?

Solution

Add the UIViewAnimationOptionCurveLinear to your animation options, like this:

[UIView animateWithDuration:speed
                      delay:delay
                    options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveLinear
                 animations:^(void){
                     [UIView setAnimationRepeatCount:5];
                     cloud.frame = (CGRectMake(cloud.frame.origin.x,   
cloud.frame.origin.y+900, cloud.frame.size.width, cloud.frame.size.height));

                 }completion:nil];

OTHER TIPS

I think you wanna try setting the "option" parameter to:

UIViewAnimationOptionCurveLinear
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top