質問

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?

役に立ちましたか?

解決

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];

他のヒント

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

UIViewAnimationOptionCurveLinear
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top