CATransition动画

来源:互联网 发布:创业软件集团 编辑:程序博客网 时间:2024/05/01 23:27
    1.   [UIView commitAnimations];
    2. [UIView beginAnimations:nil context:nil];
    3.     [UIView setAnimationRepeatAutoreverses:YES];//动画是否返回  
          [UIView setAnimationDuration:0.3];
          button.alpha =0;
  1. [UIView commitAnimations];
  2.  CATransition的type属性 
  3.   
  4.  1.#define定义的常量 
  5.      kCATransitionFade   交叉淡化过渡 
  6.      kCATransitionMoveIn 新视图移到旧视图上面 
  7.      kCATransitionPush   新视图把旧视图推出去 
  8.      kCATransitionReveal 将旧视图移开,显示下面的新视图 
  9.   
  10.  2.用字符串表示 
  11.      pageCurl            向上翻一页 
  12.      pageUnCurl          向下翻一页 
  13.      rippleEffect        滴水效果 
  14.      suckEffect          收缩效果,如一块布被抽走 
  15.      cube                立方体效果 
  16.      oglFlip             上下翻转效果  

  17.   
  18. - (void)MyCAnimation1 {   
  19.       
  20.     CATransition *animation = [CATransition animation];  
  21.     //动画时间  
  22.     animation.duration = 1.0f;  
  23.     //动画加减速 
  24.     animation.timingFunction = UIViewAnimationCurveEaseInOut;  
  25.     //过渡效果  
  26.     animation.type = kCATransitionMoveIn;  
  27.     //过渡方向  
  28.     animation.subtype = kCATransitionFromTop;  
  29.     //添加动画  
  30.     [imageView.layer addAnimation:animation forKey:nil];  
  31. }  
  32.   
  33. - (void)MyCAnimation2 {   
  34.       
  35.     CATransition *animation = [CATransition animation];  
  36.     //动画时间  
  37.     animation.duration = 1.0f;  
  38.     //动画加减速  
  39.     animation.timingFunction = UIViewAnimationCurveEaseInOut;  
  40.     //在动画执行完时是否被移除  
  41.     animation.removedOnCompletion = NO;  
  42.     //过渡效果  
  43.     animation.type = @"pageCurl";  
  44.     //过渡方向  
  45.     animation.subtype = kCATransitionFromRight;  
  46.     //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果  
  47.     animation.fillMode = kCAFillModeForwards;  
  48.     //动画停止(在整体动画的百分比).  
  49.     animation.endProgress = 0.7;  
  50.     [imageView.layer addAnimation:animation forKey:nil];  
  51. }  
  52.   
  53. - (void)MyCAnimation3 {   
  54.       
  55.     CATransition *animation = [CATransition animation];  
  56.     //动画时间  
  57.     animation.duration = 1.0f;  
  58.     //动画加减速  
  59.     animation.timingFunction = UIViewAnimationCurveEaseInOut;  
  60.     //过渡效果  
  61.     animation.type = @"pageUnCurl";  
  62.     //过渡方向  
  63.     animation.subtype = kCATransitionFromRight;  
  64.     //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果  
  65.     animation.fillMode = kCAFillModeBackwards;  
  66.     //动画开始(在整体动画的百分比).  
  67.     animation.startProgress = 0.3;  
  68.     [imageView.layer addAnimation:animation forKey:nil];  
  69. }  
  70.   
  71. - (void)MyCAnimation4 {   
  72.       
  73.     [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(updateButterfly) userInfo:nil repeats:YES];  
  74. }  
  75.   
  76. - (void)updateButterfly {  
  77.   
  78.     butterflyView.animationDuration = 0.75f;  
  79.     [self.view addSubview:butterflyView];  
  80.     [butterflyView startAnimating];  
  81.     butterflyView.center = [butterflyView randomCenterInView:self.view withInset:10.0f];  
  82.   
0 0