zoukankan      html  css  js  c++  java
  • UIViewAnimation动画与Core Animation的CATransition类动画

    1. - (void)leftClick {   
    2.   
    3.     [UIView beginAnimations:nil context:nil];  
    4.     //display mode, slow at beginning and end  
    5.     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
    6.     //动画时间  
    7.     [UIView setAnimationDuration:1.0f];  
    8.     //使用当前正在运行的状态开始下一段动画  
    9.     [UIView setAnimationBeginsFromCurrentState:YES];  
    10.     //给视图添加过渡效果  
    11.     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:imageView cache:YES];  
    12.     [UIView commitAnimations];  
    13. }  
    14.   
    15. - (void)rightClick {  
    16.       
    17.     [UIView beginAnimations:nil context:nil];  
    18.     //display mode, slow at beginning and end  
    19.     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
    20.     //动画时间  
    21.     [UIView setAnimationDuration:1.0f];  
    22.     //使用当前正在运行的状态开始下一段动画  
    23.     [UIView setAnimationBeginsFromCurrentState:YES];  
    24.     //给视图添加过渡效果  
    25.     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:imageView cache:YES];  
    26.     [UIView commitAnimations];  
    27.       
    28. }  
    29.   
    30. - (void)upClick {   
    31.       
    32.     [UIView beginAnimations:nil context:nil];  
    33.     //display mode, slow at beginning and end  
    34.     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
    35.     //动画时间  
    36.     [UIView setAnimationDuration:1.0f];  
    37.     //使用当前正在运行的状态开始下一段动画  
    38.     [UIView setAnimationBeginsFromCurrentState:YES];  
    39.     //给视图添加过渡效果  
    40.     [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:imageView cache:YES];  
    41.     [UIView commitAnimations];  
    42. }  
    43. - (void)downClick {   
    44.       
    45.     [UIView beginAnimations:nil context:nil];  
    46.     //display mode, slow at beginning and end  
    47.     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
    48.     //动画时间  
    49.     [UIView setAnimationDuration:1.0f];  
    50.     //使用当前正在运行的状态开始下一段动画  
    51.     [UIView setAnimationBeginsFromCurrentState:YES];  
    52.     //给视图添加过渡效果  
    53.     [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:imageView cache:YES];  
    54.     [UIView commitAnimations];  
    55. }  
    56.   
    57. /*    
    58.  CATransition的type属性 
    59.   
    60.  1.#define定义的常量 
    61.      kCATransitionFade   交叉淡化过渡 
    62.      kCATransitionMoveIn 新视图移到旧视图上面 
    63.      kCATransitionPush   新视图把旧视图推出去 
    64.      kCATransitionReveal 将旧视图移开,显示下面的新视图 
    65.   
    66.  2.用字符串表示 
    67.      pageCurl            向上翻一页 
    68.      pageUnCurl          向下翻一页 
    69.      rippleEffect        滴水效果 
    70.      suckEffect          收缩效果,如一块布被抽走 
    71.      cube                立方体效果 
    72.      oglFlip             上下翻转效果   
    73. */  
    74. - (void)MyCAnimation1 {   
    75.       
    76.     CATransition *animation = [CATransition animation];  
    77.     //动画时间  
    78.     animation.duration = 1.0f;  
    79.     //display mode, slow at beginning and end  
    80.     animation.timingFunction = UIViewAnimationCurveEaseInOut;  
    81.     //过渡效果  
    82.     animation.type = kCATransitionMoveIn;  
    83.     //过渡方向  
    84.     animation.subtype = kCATransitionFromTop;  
    85.     //添加动画  
    86.     [imageView.layer addAnimation:animation forKey:nil];  
    87. }  
    88.   
    89. - (void)MyCAnimation2 {   
    90.       
    91.     CATransition *animation = [CATransition animation];  
    92.     //动画时间  
    93.     animation.duration = 1.0f;  
    94.     //display mode, slow at beginning and end  
    95.     animation.timingFunction = UIViewAnimationCurveEaseInOut;  
    96.     //在动画执行完时是否被移除  
    97.     animation.removedOnCompletion = NO;  
    98.     //过渡效果  
    99.     animation.type = @"pageCurl";  
    100.     //过渡方向  
    101.     animation.subtype = kCATransitionFromRight;  
    102.     //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果  
    103.     animation.fillMode = kCAFillModeForwards;  
    104.     //动画停止(在整体动画的百分比).  
    105.     animation.endProgress = 0.7;  
    106.     [imageView.layer addAnimation:animation forKey:nil];  
    107. }  
    108.   
    109. - (void)MyCAnimation3 {   
    110.       
    111.     CATransition *animation = [CATransition animation];  
    112.     //动画时间  
    113.     animation.duration = 1.0f;  
    114.     //display mode, slow at beginning and end  
    115.     animation.timingFunction = UIViewAnimationCurveEaseInOut;  
    116.     //过渡效果  
    117.     animation.type = @"pageUnCurl";  
    118.     //过渡方向  
    119.     animation.subtype = kCATransitionFromRight;  
    120.     //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果  
    121.     animation.fillMode = kCAFillModeBackwards;  
    122.     //动画开始(在整体动画的百分比).  
    123.     animation.startProgress = 0.3;  
    124.     [imageView.layer addAnimation:animation forKey:nil];  
    125. }  
    126.   
    127. - (void)MyCAnimation4 {   
    128.       
    129.     [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(updateButterfly) userInfo:nil repeats:YES];  
    130. }  
    131.   
    132. - (void)updateButterfly {  
    133.   
    134.     butterflyView.animationDuration = 0.75f;  
    135.     [self.view addSubview:butterflyView];  
    136.     [butterflyView startAnimating];  
    137.     butterflyView.center = [butterflyView randomCenterInView:self.view withInset:10.0f];  
    138.   
    139. }  
  • 相关阅读:
    io
    文件
    诚实
    没有犯错并不代表自己就是做得好
    脑力锻炼的随缘
    电路运算
    “容错率”
    GPU简介
    名与责任
    失眠和精神的思考
  • 原文地址:https://www.cnblogs.com/hellocby/p/2688952.html
Copyright © 2011-2022 走看看