我有一个翻译动画,将我的按钮从A移动到B.
那条路线看起来像这样:
1)按钮缓慢加速2)在动画中间达到速度的峰值3)当它接近结束时减速
这是我的代码
[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];
我希望我的动画始终具有相同的速度.
我怎样才能做到这一点?
添加UIViewAnimationOptionCurveLinear
到动画选项,如下所示:
[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];