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];
}
相关推荐
Digitally7 分钟前
如何在没有电脑的情况下备份 iPhone
ios·电脑·iphone
儿歌八万首20 分钟前
Flutter 混合开发指南:项目打包与原生 Android/iOS 集成
android·flutter·ios
如此风景30 分钟前
iOS SwiftUI 布局容器详解
ios
2501_9159214333 分钟前
从需求到上架,现代 iOS 开发流程的工程化方法论
android·ios·小程序·https·uni-app·iphone·webview
TouchWorld2 小时前
iOS逆向-哔哩哔哩增加3倍速播放(2)-[横屏视频-半屏播放]增加3倍速播放
ios·swift
1024小神3 小时前
xcode 中配置AR Resource Group并设置图片宽度等
ios·swiftui·ar·xcode·swift
如此风景18 小时前
iOS SwiftUI开发所有修饰符使用详解
ios
mumuWorld18 小时前
KSCrash 实现机制深度分析
ios·源码阅读
AskHarries18 小时前
Google 登录问题排查指南
flutter·ios·app
崽崽长肉肉19 小时前
Swift中的知识点总结
ios·swift