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 不只能对位置使用,它适用于所有可被添加动画效果的属性**

相关推荐
xunyan623418 小时前
第九章 JAVA常用类
java·开发语言
China_Yanhy18 小时前
AWS S3 深度配置指南:每一栏每个选项有什么作用
java·数据库·aws
秃了也弱了。18 小时前
FASTJSON库:阿里出品java界json解析库,使用与踩坑记录
java·开发语言·json
安全渗透Hacker19 小时前
参数未校验导致的DOS(服务拒绝)问题典型场景
java·安全·web安全·网络安全·安全性测试
Chan1619 小时前
微服务 - Higress网关
java·spring boot·微服务·云原生·面试·架构·intellij-idea
二哈喇子!19 小时前
JavaSE 与 JavaEE 知识点整合
java·servlet·tomcat
之歆19 小时前
Spring AI入门到实战到原理源码-多模型协作智能客服系统
java·人工智能·spring
yyy(十一月限定版)19 小时前
c++(3)类和对象(中)
java·开发语言·c++
IT 行者19 小时前
Spring Security 7 OAuth2 Token 格式选择浅析
java·后端·spring