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

相关推荐
廋到被风吹走2 分钟前
【Spring】ThreadLocal详解 线程隔离的魔法与陷阱
java·spring·wpf
星辰离彬2 分钟前
2025 IDEA运行报错:运行 xxxxApplication 时出错。命令行过长。 通过 JAR 清单或通过类路径文件缩短命令行,然后重新运行。
java·后端·intellij-idea·jar
古城小栈5 分钟前
Java 响应式编程:Spring WebFlux+Reactor 实战
java·开发语言·spring
攻心的子乐6 分钟前
sentinel使用指南 限流/熔断 微服务 ruoyi-cloud使用了
java·开发语言
zsyy@7 分钟前
Maven本地仓库有jar还会向远程仓库下载依赖的问题
java·服务器·maven
__WanG13 分钟前
screen time api - FamilyActivityPicker 获取选中应用
ios·iphone·swift
2501_9151063213 分钟前
iOS 抓包工具在不同场景的实际作用
android·macos·ios·小程序·uni-app·cocoa·iphone
FourV大大14 分钟前
iOS原生和UniApp通信
ios·uni-app·cocoa
小万是个程序员14 分钟前
IDEA 配置热部署(使用idea自带功能,无需插件)
java·ide·intellij-idea
柒.梧.15 分钟前
Java核心面试题终极总结:从基础到进阶,覆盖高频考
java·开发语言·面试