首页 > 其他 > 详细

UIView 动画

时间:2016-01-11 20:03:57      阅读:285      评论:0      收藏:0      [点我收藏+]

UIView封装的动画有三类,下面是三个category 的名字:

UIViewAnimationWithBlocks

UIViewKeyframeAnimations

UIViewAnimation

 

 

1,UIViewAnimationWithBlocks

技术分享

上面这个动画用的是 transitionWithView。 主要用途是UIView的切换。

 

        [UIView transitionWithView:self.myView1 duration:1 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionTransitionCurlUp animations:^{

            self.myView1.hidden = YES;

        } completion:^(BOOL finished) {

      

        }];

这个就是向上翻页的效果。

 

2,UIViewKeyframeAnimations

技术分享

上面的动画用的是animateKeyframesWithDuration,关键帧动画。

 

    [UIView animateKeyframesWithDuration:2 delay:0 options:UIViewKeyframeAnimationOptionBeginFromCurrentState animations:^{

        

        [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.2 animations:^{

            weafSelf.myImageView.transform = CGAffineTransformMakeRotation(45);

            weafSelf.myImageView.center = CGPointMake(200, 200);

        }];

        

        [UIView addKeyframeWithRelativeStartTime:0.1 relativeDuration:0.2 animations:^{

            weafSelf.myImageView.transform = CGAffineTransformIdentity;

            weafSelf.myImageView.center = CGPointMake(100, 150);

        }];

        

    } completion:nil];

addKeyframeWithRelativeStartTime是在关键帧动画里面的,每一帧。注意里面的时间参数和持续时间参数都是百分比,0.1代表的是十分之一的持续时间。

 

3,UIViewAnimation

技术分享

 

 上面的动画用的是下面的代码。 

    [UIView beginAnimations:@"test " context:nil];

    [UIView setAnimationDuration:1];

    [UIView setAnimationWillStartSelector:@selector(onStart)];

    [UIView setAnimationDelegate:self];

    self.myImageView.center = CGPointMake(self.myImageView.center.x + 20, self.myImageView.center.y + 20);

    [UIView commitAnimations];

在begin 和 commit 之间的代码,相当于blocks里面。

 

 

代码地址:

https://github.com/loyinglin/LearnViewAnimations

UIView 动画

原文:http://www.cnblogs.com/loying/p/5122253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!