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];
}
相关推荐
Digitally4 小时前
6 种简易方法轻松连接 iPad 与电脑
ios·电脑·ipad
2501_915921437 小时前
uni-app一键生成iOS安装包并上传TestFlight全流程
android·ios·小程序·https·uni-app·iphone·webview
sp42a7 小时前
如何在 NativeScript 中使用 iOS 的 Metal 着色器
ios·着色器·nativescript
Mr_CrazyPeter1 天前
iONSPlayer 1.1.1版本发布
游戏·ios·模拟器
秋雨梧桐叶落莳1 天前
iOS——UI入门
ui·ios·cocoa
zhensherlock1 天前
Protocol Launcher 系列:Agenda 优雅组织你的想法与日程
javascript·macos·ios·typescript·node.js·mac·ipad
Rhys..1 天前
webdriveragent setup教程
ios
报错小能手1 天前
ios开发方向——swift内存基础
开发语言·ios·swift
SY.ZHOU1 天前
移动端架构体系(二):本地持久化与动态部署
flutter·ios·安卓
Mr_Tony1 天前
iOS / SwiftUI 输入法(键盘)布局处理总结(AI版)
ios·swiftui