Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios UIView animation curves

Is there any way to do things the "short and easy" way like below? The curve appears to still use EaseOut.

[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView animateWithDuration:0.5 animations:^{
    // ... do stuff here
}];
like image 813
Jacksonkr Avatar asked Jun 11 '12 19:06

Jacksonkr


2 Answers

You are mixing two different kinds of UIView-animations. You should be using something like this either of these:

[UIView animateWithDuration:0.5
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{
                    // ... do stuff here
               } completion:NULL];

This came from the newer block-based UIView-animation API. The first line, on the other hand, is part of the older UIView animation API that looks like this:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
// ... do stuff here
[UIView commitAnimations];

They do the same thing and you can use either (though Apple recommends the block-based API since it is easier/cleaner to do callbacks after the animation finishes).

like image 88
David Rönnqvist Avatar answered Sep 18 '22 14:09

David Rönnqvist


You can do it using Core Animation , CAKeyFrameAnimation to define the curve points. See this tutorial: http://nachbaur.com/blog/core-animation-part-4

like image 30
Steve Avatar answered Sep 20 '22 14:09

Steve