iOS 中spring动画的使用

我们先来看以下两个动画的效果

上面的位移动画,一个是普通的动画,一个是spring动画,可以明显的看出来,spring动画在动画的前期更快一些,给人的感觉干脆,利落

以下是代码

复制代码
- (void)normalAnimation
{
    [UIView animateWithDuration:1 animations:^{
        self.animationView.frame = CGRectMake(10, 400, 50, 50);
    } completion:^(BOOL finished) {
        self.animationView.frame = CGRectMake(10, 100, 50, 50);
    }];
}

- (void)springAnimation
{
    [UIView animateWithDuration:1 delay:0 usingSpringWithDamping:1 initialSpringVelocity:0 options:UIViewAnimationOptionCurveLinear animations:^{
        self.animationView.frame = CGRectMake(10, 400, 50, 50);
    } completion:^(BOOL finished) {
        self.animationView.frame = CGRectMake(10, 100, 50, 50);

    }];
}

spring 动画的接口就是

UIView animateWithDuration:1 delay:0 usingSpringWithDamping:1 initialSpringVelocity:0 options:UIViewAnimationOptionCurveLinear animations:\^{ }\]; app 中很多都是用的这个动画效果,让人看起来很舒服 **Spring Animation 前期速度增加得更快,在动画时间一定的前提下,给人感觉更加快速、干净。** 我们可以通过这个图看下 ![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/8304d00a6e6146c5bb0628b5c0d03910.png) **此外,Spring Animation 不只能对位置使用,它适用于所有可被添加动画效果的属性**

相关推荐
YDS8293 分钟前
大营销平台 —— 抽奖前置规则过滤
java·spring boot·ddd
仍然.8 分钟前
多线程---CAS,JUC组件和线程安全的集合类
java·开发语言
不懂的浪漫13 分钟前
mqtt-plus 架构解析(五):错误处理与 ErrorAction 聚合策略
java·spring boot·后端·物联网·mqtt·架构
呼啦啦56120 分钟前
C++vector
java·c++·缓存
花千树-01021 分钟前
MCP + Function Calling:让模型自主驱动工具链完成多步推理
java·agent·react·mcp·toolcall·harness·j-langchain
Benszen24 分钟前
Linux容器:轻量级虚拟化革命
java·linux·运维
凸头27 分钟前
Lombok 包底层浅析
java
不懂的浪漫30 分钟前
mqtt-plus 架构解析(三):Payload 序列化与反序列化,为什么要拆成两条链
java·spring boot·物联网·mqtt·架构
卷福同学35 分钟前
去掉手机APP开屏广告,李跳跳2.2下载使用
java·后端·算法
漫霂1 小时前
二叉树的翻转
java·数据结构·算法