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];
}
相关推荐
鸿蒙布道师8 小时前
鸿蒙NEXT开发资源工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
season_zhu10 小时前
iOS开发:关于路由
ios·架构·swift
鸿蒙布道师13 小时前
鸿蒙NEXT开发设备相关工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
熊猫鹏-梓潼14 小时前
Swift Programming All in One苹果程序开发自学之路
开发语言·ios·swift
njsgcs1 天前
用swift playground写个ios应用和大模型或者网站交互
ios·swift
leluckys1 天前
swift-11-init、deinit、可选链、协议、元类型
开发语言·ios·swift
njsgcs1 天前
vscode swift hello world
开发语言·ios·swift
YungFan1 天前
SwiftUI-MLX本地大模型开发(三)
ios·llm·swiftui
请叫我飞哥@1 天前
Apple ID授权登入
ios·swiftui
weixin_452093252 天前
关于apple ios苹果mdm监管锁的漏洞与修复
ios