动画结束时会变慢

 书友51676198 发布于 2023-02-09 19:26

我有一个翻译动画,将我的按钮从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];

我希望我的动画始终具有相同的速度.

我怎样才能做到这一点?

1 个回答
  • 添加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];
    

    2023-02-09 19:29 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有