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];
}
相关推荐
Yannik14 小时前
iOS CocoaPods私有库完整搭建+踩坑实战总结
ios·cocoapods
终端安全笔记17 小时前
绕过工具把 iOS 27 列进支持范围:从它的更新节奏能读出什么
安全·ios
AIsoft_868917 小时前
线上培训录屏怎么转文字?科会通操作指南
ios·智能手机
weixin_4038101321 小时前
苹果脚本编写软件有哪些?怎么选择 iOS脚本技术路线
ios
2501_915918412 天前
在 Xcode 中运行和调试单元测试的完整指南
ide·vscode·macos·ios·单元测试·个人开发·xcode
茉莉玫瑰花茶2 天前
GO [ 标准库 · HTTP 高可用 ]
ios·iphone·xcode
用户1202687863862 天前
过审了,国区搜不到
ios
用户38034165882972 天前
八个私有 SPM 包撑起六款 App:分支当版本、钻石依赖,和一次谁都没报错的失效
ios·swift
老李IT笔记2 天前
远程取设备日志:iOS、tvOS 和 macOS 三端的同意方式不一样
macos·ios