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];
}
相关推荐
Magnetic_h1 小时前
【iOS】设计模式复习
笔记·学习·ios·设计模式·objective-c·cocoa
00后程序员张3 小时前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
前端小超超3 小时前
capacitor配置ios应用图标不同尺寸
ios·蓝桥杯·cocoa
2501_915106324 小时前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
kymjs张涛7 小时前
零一开源|前沿技术周刊 #16
ios·apple·hacker news
2301_821046527 小时前
Python与Go结合
ios·iphone
他们都不看好你,偏偏你最不争气8 小时前
【iOS】AFNetworking
开发语言·macos·ios·objective-c
zhanggui10 小时前
iOS Debug Symbols
ios·xcode·debug symbox
库奇噜啦呼15 小时前
【iOS】static、const、extern关键字
ios
zzywxc78716 小时前
AI工具全景洞察:从智能编码到模型训练的全链路剖析
人工智能·spring·ios·prompt·ai编程