zoukankan      html  css  js  c++  java
  • UI Animation 动画效果

      1 - (void)buttonClicked:(UIButton *)button  
      2 {  
      3     // UIView 动画  
      4     // 1.最简单的动画实现  
      5     // 参数1:动画执行一次需要的时间  
      6     // 参数2:动画执行的内容(写动画执行的结果)  
      7 //    [UIView animateWithDuration:10.0 animations:^{  
      8 //        button.alpha = 0.38;  
      9 //        button.backgroundColor = [UIColor blueColor];  
     10 //        button.frame = CGRectMake(0, 0, 320, 100);  
     11 //    }];  
     12       
     13       
     14       
     15       
     16     // 参数3:动画执行结束后 要执行的代码  
     17 //    [UIView animateWithDuration:1.f animations:^{  
     18 //          
     19 //        // 对动画本身设置  
     20 //          
     21 //        // 可以给动画一个还原效果  
     22 //        [UIView setAnimationRepeatAutoreverses:YES];  
     23 //        // 动画重复的次数  
     24 //        [UIView setAnimationRepeatCount:1.25];  
     25 //        // 动画延迟几秒执行  
     26 //       // [UIView setAnimationDelay:1.0];  
     27 //        // 动画运行的速度曲线  
     28 //        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];  
     29 //          
     30 //        button.backgroundColor = [UIColor blueColor];  
     31 //        button.bounds = CGRectMake(0, 0, 200, 200);  
     32 //    } completion:^(BOOL finished) {  
     33 //        NSLog(@"动画完毕");  
     34 //    }];  
     35       
     36       
     37       
     38     // 3.  
     39       
     40     // 参数3:动画的选项 在这里一般写 速度曲线  
     41 //    [UIView animateKeyframesWithDuration:1.f delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{  
     42 //        button.frame = CGRectMake(0, 0, 200, 200);  
     43 //    } completion:nil];  
     44       
     45       
     46       
     47     //4.  
     48       
     49 //    [UIView animateWithDuration:1.f delay:0 usingSpringWithDamping:0.05 initialSpringVelocity:0.4 options:UIViewAnimationOptionCurveEaseIn animations:^{  
     50 //        button.frame = CGRectMake(0, 0, 200, 200);  
     51 //    } completion:nil];  
     52   
     53       
     54       
     55     // transition动画  
     56       
     57 //    [UIView transitionWithView:button duration:1.f options:UIViewAnimationOptionTransitionCurlDown animations:^{  
     58 //        button.frame = CGRectMake(0, 0, 200, 200);  
     59 //    } completion:nil];  
     60       
     61       
     62       
     63     // 把第一个视图移除 把第二个视图 添加到父视图上  
     64       
     65 //    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];  
     66 //    view.backgroundColor = [UIColor blueColor];  
     67 //    // 参数1;要移除的view  
     68 //    // 参数2:要添加的view  
     69 //    [UIView transitionFromView:button toView:view duration:1.f options:UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished) {  
     70 //      
     71 //    }];  
     72       
     73       
     74       
     75     // CAAnimation layer层动画  
     76       
     77     // CAPropertyAnimation 是一个抽象类  
     78     // 1. CABasicAnimation 的使用  
     79       
     80 //    CABasicAnimation *animation1 = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"];  
     81 //    // 从什么状态开始放大  
     82 //    animation1.fromValue = [NSNumber numberWithInt:1];  
     83 //    // 到什么状态结束  
     84 //    animation1.toValue = [NSNumber numberWithInt:3];  
     85 //    // 动画执行的时间  
     86 //    animation1.duration = 1.f;  
     87 //    // 是否有一个恢复  
     88 //    animation1.autoreverses = YES;  
     89 //    animation1.repeatCount = NSIntegerMax;  
     90 //      
     91 //      
     92 //    CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];  
     93 //      
     94 //    // 从什么状态开始放大  
     95 //    animation2.fromValue = [NSNumber numberWithInt:1];  
     96 //    // 到什么状态结束  
     97 //    animation2.toValue = [NSNumber numberWithInt:M_PI * 2];  
     98 //    // 动画执行的时间  
     99 //    animation2.duration = 2.f;  
    100 //    // 是否有一个恢复  
    101 ////    animation2.autoreverses = YES;  
    102 //    animation2.repeatCount = NSIntegerMax;  
    103 //      
    104 //      
    105 //      
    106 //    // 组动画 将几个动画组合到一起 同时执行  
    107 //      
    108 //    CAAnimationGroup *group = [CAAnimationGroup animation];  
    109 //    group.animations = @[animation1,animation2];  
    110 //    // 将动画 添加到组动画之后 每个动画自己的设置将失效  
    111 //    group.duration = 3.f;  
    112 //    group.autoreverses = YES;  
    113 //    group.repeatCount = NSIntegerMax;  
    114 //      
    115 //    [button.layer addAnimation:group forKey:@"111"];  
    116 //      
    117 //      
    118 //      
    119 //    [button.layer addAnimation:animation2 forKey:@"111"];  
    120       
    121       
    122       
    123       
    124 //    // 关键帧动画  
    125 //    CAKeyframeAnimation *keyFrameAni = [CAKeyframeAnimation animationWithKeyPath:@"position"];  
    126 //      
    127 //    // 产生一个路径  
    128 //    CGMutablePathRef path = CGPathCreateMutable();  
    129 //    // 设定一个初始点  
    130 //    CGPathMoveToPoint(path, nil, 100, 100);  
    131 //      
    132 //    // 添加一个路过的点(添加一条直线的路径)  
    133 //    CGPathAddLineToPoint(path, NULL, 200, 100);  
    134 //    CGPathAddLineToPoint(path, NULL, 300, 0);  
    135 //    CGPathAddLineToPoint(path, NULL, 10, 200);  
    136 //    CGPathAddLineToPoint(path, NULL, 30, 0);  
    137 //    CGPathAddLineToPoint(path, NULL, 150, 40);  
    138 //    CGPathAddLineToPoint(path, NULL, 300, 0);  
    139 //      
    140 //      
    141 //    // 添加一条曲线路径  
    142 //    CGPathAddCurveToPoint(path, NULL, 10, 20, 100, 300, 150, 100);  
    143 //    CGPathAddCurveToPoint(path, NULL, 100, 150, 100, 0, 150, 100);  
    144 //    CGPathAddCurveToPoint(path, NULL, 120, 230, 105, 542, 10, 10);  
    145 //      
    146 //    // 设置路径信息  
    147 //    [keyFrameAni setPath:path];  
    148 //    // 设置执行时间  
    149 //    [keyFrameAni setDuration:5.f];  
    150 //      
    151 //    [button.layer addAnimation:keyFrameAni forKey:@"222"];  
    152       
    153       
    154       
    155       // 过渡 变形  
    156 //    CATransition *transition = [CATransition animation];  
    157 //      
    158 //    // 过渡动画CATransition 依靠type/subType改变动画效果  
    159 //    transition.duration = 2.f;  
    160 //      
    161 //    // 动画类型  
    162 //    //[transition setType:kCATransitionMoveIn];  
    163 //    [transition setType:@"cameraIrisHollowClose"];  
    164 //    // 动画方向  
    165 //    [transition setSubtype:kCATransitionFromLeft];  
    166 //      
    167 //    [button.layer addAnimation:transition forKey:@"333"];  
    168 }  
    有人说:爱上一座城,是因为城里住着某个人,能够与所爱的人在一起,连光阴都是美的。即便粗茶淡饭,修篱种田,只要有你陪伴就好。那么,找一个青山绿水的地方,寻一处幽静的茅舍,或是云水禅心的庭院,那里有晴朗的阳光和静谧的悠然,还有你明媚的笑脸。掬一捧花香在平淡的日子,握着一路相随的暖意,让爱的馨香在柴米油盐中升腾;在一杯茶的温情里,体味生活的诗意;在一碗粥的清淡中,感受生活的浪漫,每天清晨你和阳光都在,便是我的幸福。——春暖花开 《择一城终老,遇一人白首》
  • 相关阅读:
    在安装了Anaconda+Pycharm怎么导入OpenCV
    JS--ECMAScript
    JS--DOM
    JS-BOM
    浮动 高度塌陷
    CSS2--字体样式
    CSS2--文本样式
    css2--垂直对齐
    css2--背景
    HTML基础
  • 原文地址:https://www.cnblogs.com/-Eric-Liu/p/5564002.html
Copyright © 2011-2022 走看看