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];
}
相关推荐
CHB1 天前
uni-app x 蒸汽模式 性能测试基准报告 Benchmark【Android版】
android·ios·uni-app
Magic-ZYJ2 天前
不登录、不联网也能用:我是如何设计一款“本地优先”iOS App 的
ios·app·iphone·研发·独立开发者·心情日记
_阿南_2 天前
flutter 展示的字体突然奔放了
android·flutter·ios
90后的晨仔2 天前
你的 iOS 最低部署版本即将不再被 App Store 接受
ios
2601_965798472 天前
Launch Your Wellness App Fast: The Truth About Meditation Source Code
前端·macos·ios·objective-c·cocoa
初级代码游戏2 天前
iOS开发 Swift 速记7:结构体和类
开发语言·ios·swift
Anhty3 天前
手机端叮咚变声器2026实测:功能表现、优缺点完整解析
功能测试·ios·智能手机·安卓
SameX3 天前
后台定位耗电的问题,我花两年把它压到了3%-5%
ios
星辰即远方3 天前
计算器仿写总结
学习·ui·ios·cocoa·xcode
游戏开发爱好者83 天前
系统状态:专为iPhone和iPad设计的实时系统性能监控工具全面介绍
android·ios·小程序·uni-app·iphone·webview·ipad