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

相关推荐
学到头秃的suhian5 小时前
Maven
java·maven
小坏讲微服务5 小时前
Docker-compose 搭建Maven私服部署
java·spring boot·后端·docker·微服务·容器·maven
chxii5 小时前
Maven 详解(下)
java·maven
inferno5 小时前
Maven基础(二)
java·开发语言·maven
杨武博5 小时前
关于maven中pom依赖冲突问题记录
java·maven
陈果然DeepVersion7 小时前
Java大厂面试真题:Spring Boot+Kafka+AI智能客服场景全流程解析(十)
java·spring boot·ai·kafka·面试题·向量数据库·rag
胖虎17 小时前
iOS 应用网络权限弹窗的问题及解决方案
ios·网络请求·权限弹窗
但要及时清醒7 小时前
ArrayList和LinkedList
java·开发语言
一叶飘零_sweeeet7 小时前
从测试小白到高手:JUnit 5 核心注解 @BeforeEach 与 @AfterEach 的实战指南
java·junit