zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    (C#基础) byte[] 之初始化, 赋值,转换。
    System.IO.IOException: The handle is invalid.
    .NET 自动内存管理(垃圾收集GC)
    Inconsistent accessibility
    有用的网址
    dw添加emmet
    行内标签,怎么取消两个标签中间的距离
    2016.6.2近日学习计划
    HTML5 input placeholder 颜色修改示例
    加入收藏和设为首页
  • 原文地址:https://www.cnblogs.com/loying/p/5122253.html
Copyright © 2011-2022 走看看