UIView animateWithDuration: duration: animations: completion: seems to have a default transition?

27,245

Solution 1

You can change this setting by using the animateWithDuration:delay:options:animations:completion: alternative. Send an UIViewAnimationOption mask for the option parameter. These are the options that you're interested in :

 UIViewAnimationOptionCurveEaseInOut 
 UIViewAnimationOptionCurveEaseIn   
 UIViewAnimationOptionCurveEaseOut 
 UIViewAnimationOptionCurveLinear 

The documentation says that UIViewAnimationOptionCurveEaseInOut is the default value.

See the documentation for more details : http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html

Solution 2

You should use, that will solve your problem

[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveLinear  animations:^{
        //code with animation
    } completion:^(BOOL finished) {
        //code for completion
    }];
Share:
27,245
Fitzy
Author by

Fitzy

Donate: Bitcoin: 18YFRUwQne2cPivXSGWL7AffoCK2qR71Bi Ethereum: 0xAD66D5F9BC59924152361ce4B58aA8fa63A9a9Ae

Updated on February 24, 2020

Comments

  • Fitzy
    Fitzy about 4 years

    In my program, I want to create an animation that will move at a constant speed. It appears that the animation starts slowly, speeds up and then finishes slowly. Is there any way to change this?