iOS实现弹簧放大动画

效果图

实现代码

复制代码
- (void)setUpContraints
{
    CGFloat topImageCentery = (SCREEN_HEIGHT - 370 * PLUS_SCALE) / 2;
    [self.topIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.centerY.equalTo(self.view.mas_top).with.offset(topImageCentery);
    }];
    [self.view layoutIfNeeded];
}

- (void)topAnimation
{
    CASpringAnimation *springAnimation = [CASpringAnimation animationWithKeyPath:@"transform.scale"];
    springAnimation.mass = 1.5;
    springAnimation.stiffness = 400;
    springAnimation.damping = 20;
    springAnimation.initialVelocity = 0;
    springAnimation.duration = 1;
    springAnimation.fromValue = @0;
    springAnimation.toValue = @1;
    springAnimation.fillMode = kCAFillModeBoth;
    springAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [self.topIconView.layer addAnimation:springAnimation forKey:nil];
}
相关推荐
白狐_7982 小时前
【深度拆解】2026年数字化学习流:iPad 主动式电容笔的技术底层与选型实测
学习·ios·ipad·电容笔
2501_915918413 小时前
快蝎iOS开发IDE:免Xcode开发,支持Swift/Flutter项目
ide·vscode·ios·个人开发·xcode·swift·敏捷流程
空中海11 小时前
第十二章:iOS高级系统能力与 UIKit 互操作
ios
songgeb18 小时前
用 AI 降低 iOS 客户端 UI 自动化测试难度
ios·测试
我现在不喜欢coding19 小时前
Swift 核心协议揭秘:从 Sequence 到 Collection,你离标准库设计者只差这一步
ios·swift
开心就好202519 小时前
使用Edge和ADB进行Android Webview远程调试的完整教程
前端·ios
开心就好202521 小时前
iOS应用上架全流程:从证书申请到发布避坑指南
后端·ios
梦想不只是梦与想1 天前
flutter 与 Android iOS 通信?以及实现原理(一)
android·flutter·ios·methodchannel·eventchannel·basicmessage
冰凌时空1 天前
30 Apps 第 1 天:待办清单 App —— 数据层完整设计
前端·ios
2501_915909061 天前
Xcode从入门到精通:全面解析iOS开发IDE的核心功能与实际应用指南
ide·vscode·ios·个人开发·xcode·swift·敏捷流程