果冻弹簧效果动画

//在点击button时加入这句话就行

// 果冻弹簧效果动画

    CABasicAnimation *scaleAnimation1 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

    scaleAnimation1.fromValue = [NSNumber numberWithFloat:1.0];

    scaleAnimation1.toValue = [NSNumber numberWithFloat:1.2];

    [scaleAnimation1 setBeginTime:0.0f];

    [scaleAnimation1 setDuration:0.1f];

    

    CABasicAnimation *scaleAnimation2 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

    scaleAnimation2.fromValue = [NSNumber numberWithFloat:1.2];

    scaleAnimation2.toValue = [NSNumber numberWithFloat:1.05];

    [scaleAnimation2 setBeginTime:0.1f];

    [scaleAnimation2 setDuration:0.1f];

    

    CABasicAnimation *scaleAnimation3 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

    scaleAnimation3.fromValue = [NSNumber numberWithFloat:1.05];

    scaleAnimation3.toValue = [NSNumber numberWithFloat:1.15];

    [scaleAnimation3 setBeginTime:0.2f];

    [scaleAnimation3 setDuration:0.1f];

    

    CABasicAnimation *scaleAnimation4 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

    scaleAnimation4.fromValue = [NSNumber numberWithFloat:1.15];

    scaleAnimation4.toValue = [NSNumber numberWithFloat:1.05];

    [scaleAnimation4 setBeginTime:0.3f];

    [scaleAnimation4 setDuration:0.1f];

    

    CAAnimationGroup *animationGroup = [CAAnimationGroup animation];

    

    animationGroup.duration = 0.4f;

    

    [animationGroup setAnimations:[NSArray arrayWithObjects:scaleAnimation1,scaleAnimation2, scaleAnimation3,scaleAnimation4, nil]];

    

    [button.layer addAnimation:animationGroup forKey:nil];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值