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];
}
相关推荐
Andy_GF15 小时前
iOS26 系统适配-直接隐藏 UIBarButtonItem 的 Liquid glass 效果
ios
wjm04100618 小时前
ios学习路线-- swift基础2
学习·ios·swift
开心就好202518 小时前
全面解析WhatsApp Web抓包:原理、工具与安全
后端·ios
程序喵大人20 小时前
OpenClaw的成功是AI Agent的“iPhone时刻”吗?
人工智能·ios·iphone·openclaw
marteker20 小时前
苹果的冰球营销:用iPad设计面具,讲述科技之外的情感故事
科技·ios·ipad
H_老邪1 天前
贪心算法的应用
算法·ios·贪心算法
UXbot1 天前
APP原型生成工具测评
android·前端·人工智能·低代码·ios·开发·app原型
游戏开发爱好者81 天前
如何使用Instruments和Keymob进行Swift应用性能优化分析
开发语言·ios·性能优化·小程序·uni-app·iphone·swift
2501_916008891 天前
移动应用上架到应用商店的完整指南:原理与详细步骤
android·ios·小程序·https·uni-app·iphone·webview
你好龙卷风!!!1 天前
uni-app 项目 iOS 个人免费真机调试打包全流程手册
ios·uni-app