I'm trying to move a label from point A to point B using UIView animateWithDuration as below
[UIView animateWithDuration:3 delay:0 options:UIViewAnimationTransitionNone animations:^(void){
label.alpha = 1;
label.center = CGPointMake(label.center.x , label.center.y +740);
}completion:^(BOOL Finished){
label.alpha = 0;
label.center = CGPointMake(label.center.x , label.center.y - 740);]
Once the label is about to reach 740, it decelrates. Is it possible to have uniform motion to point B instead of slowing down?
Use this:
[UIView animateWithDuration:3 delay:0 options:UIViewAnimationTransitionNone | UIViewAnimationOptionCurveLinear animations:^(void){
...
Just change the animation option to UIViewAnimationOptionCurveLinear
to have the animation use remove all the acceleration and deceleration or UIViewAnimationOptionCurveEaseIn
to keep the slow start without decelerating at the end.
What you are seeing is expected and even documented (see below). By default the animation both begins and ends slowly:
DiscussionThis method performs the specified animations immediately using the
UIViewAnimationOptionCurveEaseInOut
.
Include UIViewAnimationCurveLinear
in the options instead of UIViewAnimationTransitionNone
. UIViewAnimationTransitionNone
is not meant for this kind of animation. It's meant for view controller transitions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.