• UIView 动画


    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

  • 相关阅读:
    软件工程第一次作业
    Python正则表达式学习摘要
    个人作业——软件工程实践总结作业
    个人作业——软件评测
    软件工程实践2019第五次作业--结对编程的实现
    软件工程实践2019第四次作业
    软件工程实践2019第三次作业
    软件工程实践2019第二次作业
    软件工程实践2019第一次作业
    个人作业——软件工程实践总结&个人技术博客
  • 原文地址:https://www.cnblogs.com/loying/p/5122253.html
Copyright © 2020-2023  润新知