IOS动画实现方式 - 旋转 - 放大

1.旋转

    CABasicAnimation *animation =  [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    //默认是顺时针效果,若将fromValue和toValue的值互换,则为逆时针效果
    animation.fromValue = [NSNumber numberWithFloat:M_PI *2];
    animation.toValue =  [NSNumber numberWithFloat: 0.f];
    animation.duration  = 1.5;                  //一次时间
    animation.autoreverses = NO;                         //是否自动回倒
    animation.fillMode =kCAFillModeForwards;
    animation.removedOnCompletion = NO;           //设置进入后台动画不停止
    animation.repeatCount = CGFLOAT_MAX ;            //重复次数
    animation.delegate = self;                    //动画代理
    [gifImageView.layer addAnimation:animation forKey:nil];

2.放大

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animation.toValue = [NSNumber numberWithFloat:1.5f];
    CABasicAnimation *ani1 = [CABasicAnimation animationWithKeyPath:@"opacity"];
    ani1.toValue = [NSNumber numberWithFloat:0.1f];
    
    CAAnimationGroup *anGroup = [CAAnimationGroup animation];
    anGroup.animations = @[animation,ani1];
    anGroup.duration = 1.f;
    anGroup.autoreverses = NO;
    anGroup.repeatCount = CGFLOAT_MAX;
    anGroup.removedOnCompletion = NO; //设置进入后台动画不停止
    [imageView1.layer addAnimation:anGroup forKey:@"a"];
    [UIView animateWithDuration:0.5 animations:^{
        imageView2.alpha = 1.0f;
    }completion:^(BOOL finished) {
        [imageView2.layer addAnimation:anGroup forKey:@"b"];
    }];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容