美文网首页
iOS缩放动画

iOS缩放动画

作者: LWide | 来源:发表于2020-11-30 15:49 被阅读0次

    //缩放动画 CAKeyframeAnimation(关键帧动画)

    - (void) shakeToShow:(UIView *)aView
    {
        CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
        animation.duration = 0.6;// 动画时间
        NSMutableArray *values = [NSMutableArray array];
        // 前两个是控制view的大小的;
        [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
        [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 1.0)]];
        [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
        animation.values = values;
        [aView.layer addAnimation:animation forKey:nil];
    }
    

    //UIView动画方式

    - (void)scaleAnimation {
        [UIView animateWithDuration:0.1 animations:^{
            self.transform = CGAffineTransformMakeScale(1.5, 1.5);
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:0.1 animations:^{
                self.transform = CGAffineTransformMakeScale(0.9, 0.9);
            } completion:^(BOOL finished) {
                [UIView animateWithDuration:0.12 animations:^{
                    self.transform = CGAffineTransformMakeScale(1.1, 1.1);
                } completion:^(BOOL finished) {
                    [UIView animateWithDuration:0.12 animations:^{
                        self.transform = CGAffineTransformMakeScale(1.0, 1.0);
                    }];
                }];
            }];
        }];
    }
    

    相关文章

      网友评论

          本文标题:iOS缩放动画

          本文链接:https://www.haomeiwen.com/subject/qmorwktx.html