IOS几种实现动画的方式

1. 使用基本关键帧动画CABasicAnimation

特点:可做3D动画

详细介绍可参看两个帖子:
http://blog.csdn.net/iosevanhuang/article/details/14488239
http://blog.csdn.net/wscqqlucy/article/details/8669636

注:( CGAffineTransform CATransform3D 的比较 )
CGAffineTransform is used for 2-D manipulation of NSViews, UIViews, and other 2-D Core Graphics elements.
CATransform3D is a Core Animation structure that can do more complex 3-D manipulations of CALayers.( 搬运from stackOverFlow)

如:

CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
    animation.fromValue = @(0);
    animation.toValue = @(-M_PI);
    animation.repeatCount = 0;
    animation.duration = 0.4;

    [aUIView.layer addAnimation:animation forKey:@"rotation"];

    CATransform3D transform = CATransform3DIdentity;
    transform.m34 = 1.0 / 500.0;
    aUIView.layer.transform = transform;

2. 使用UIView关键帧动画animateKeyframesWithDuration

如:

[UIView animateKeyframesWithDuration:durationTime delay:0 options:0 animations:^{

        [UIView addKeyframeWithRelativeStartTime:0*frameDuration relativeDuration:1*frameDuration animations:^{

            weakSelf.pickGradeView.transform = CGAffineTransformMakeScale(0.01, 0.01);

        }];

        [UIView addKeyframeWithRelativeStartTime:1*frameDuration relativeDuration:1*frameDuration animations:^{

            weakSelf.pickGradeView.alpha = 1.0;

        }];

    } completion:^(BOOL finished) {

    }];

3.使用UIView animateWithDuration

如:

    __weak typeof(self) weakSelf = self;
    [UIView animateWithDuration:1.0 delay:0.0 usingSpringWithDamping:1.0 initialSpringVelocity:0.5 options:0 animations:^{

        __strong typeof(weakSelf) strongSelf = weakSelf;

        strongSelf.shortNameLabel.transform = CGAffineTransformMakeScale(0.8, 0.8);

    } completion:^(BOOL finished) {

        [UIView animateWithDuration:0.4 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:0 animations:^{

            __strong typeof(weakSelf) strongSelf = weakSelf;

            strongSelf.shortNameLabel.transform = CGAffineTransformMakeScale(1.0, 1.0);

        } completion:nil];

    }];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值