跳转

作者: syh1234 | 来源:发表于2018-06-25 15:00 被阅读0次

        _imgView.image = [UIImage imageNamed:@"123"];

        _imgView.alpha = 0.0;


    - (IBAction)danru:(id)sender {

        [UIView beginAnimations:nil context:nil];//标记动画块开始

        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];//定义动画加速和减速方式

        [UIView setAnimationDuration:0.5];//动画时长

        [UIView setAnimationDelegate:self];

        _imgView.alpha = 1.0;

        //动画结束后回调方法

        [UIView commitAnimations];//标志动滑块结束

    }

    - (IBAction)suofang:(id)sender {

        //缩放动画

        CABasicAnimation* caBaseBounds = [CABasicAnimation animation];

        caBaseBounds.duration = 2;

        caBaseBounds.keyPath = @"bounds";

        caBaseBounds.removedOnCompletion = NO;

        caBaseBounds.fillMode = kCAFillModeForwards;

        caBaseBounds.fromValue = [NSValue valueWithCGRect:_imgView.layer.frame];/*动画完了也没变啊~*/

        caBaseBounds.toValue = [NSValue valueWithCGRect:CGRectMake(_imgView.layer.frame.origin.x,

                                                                  _imgView.layer.frame.origin.y,

                                                                  _imgView.layer.frame.size.width / 2,

                                                                  _imgView.layer.frame.size.height * 2)];

        [_imgView.layer addAnimation:caBaseBounds forKey:nil];

    }

    - (IBAction)xuanzhuan:(id)sender {

        //旋转动画

        CABasicAnimation* caBaseTransform = [CABasicAnimation animation];

        caBaseTransform.duration = 2;

        caBaseTransform.keyPath = @"transform";

        caBaseTransform.removedOnCompletion = NO;

        caBaseTransform.fillMode = kCAFillModeForwards;

        caBaseTransform.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0, 0, 1)];

        caBaseTransform.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(- M_PI / 2, 0, 0, 1)];

        [_imgView.layer addAnimation:caBaseTransform forKey:nil]; 

    }

    - (IBAction)pingyi:(id)sender {

        //平移动画

        CABasicAnimation* caBasePosition = [CABasicAnimation animation];

        caBasePosition.duration = 2;

        caBasePosition.keyPath = @"position";

        caBasePosition.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];

        caBasePosition.toValue = [NSValue valueWithCGPoint:CGPointMake(0, 300)];

        caBasePosition.removedOnCompletion = NO;

        caBasePosition.fillMode = kCAFillModeForwards;

        [_imgView.layer addAnimation:caBasePosition forKey:nil];

    }

    相关文章

      网友评论

          本文标题:跳转

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