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];
}
相关推荐
鹏多多2 天前
Flutter下拉刷新上拉加载侧拉刷新插件:easy_refresh全面使用指南
android·前端·ios
驱动探索者2 天前
[缩略语大全]之[IOS]篇
ios
kkk_皮蛋3 天前
在移动端使用 WebRTC (Android/iOS)
android·ios·webrtc
Swift社区3 天前
如何在 SwiftUI 中对 CoreImage 滤镜做实时预览
ios·swiftui·cocoa
ipad协议开发3 天前
企业微信iPad协议的开发进程
ios·企业微信·ipad
七月巫山晴3 天前
【iOS】OC中的一些宏
前端·ios·objective-c
初级代码游戏3 天前
iOS开发 SwiftUI Text的基本用法
ios·swiftui·swift
TheNextByte14 天前
如何安全有效地清除iPad数据以便出售?
安全·ios·ipad
十二测试录4 天前
Android和iOS测试区别
android·经验分享·ios·职场发展·ab测试
张飞签名上架4 天前
深耕全球市场:App上架iOS与Google Play全流程指南
macos·ios·cocoa·ios上架·上架·谷歌上架