UIViewAnimation动画与Core Animation的CATransition类动画

来源:互联网 发布:电脑闹钟提醒软件 编辑:程序博客网 时间:2024/06/05 15:26
  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. }  
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 迅雷登录太频繁怎么办 糖果手机声音小怎么办 产品出现了问题怎么办 插头螺丝太紧怎么办 宜家儿童乐园怎么办卡 泰国旅游有蚊子怎么办 啦泰国旅游拉肚子怎么办 电动车上不了牌怎么办 电动车电压低了怎么办 电车显示器不亮怎么办 电动车故障显示m怎么办 电动车上面出现m怎么办 佰仟乐购额度没有了怎么办 交易密码忘记了怎么办? 电脑打开没网怎么办 网络配适器无法运行怎么办 电脑dns没有响应怎么办 win7系统没有网上邻居怎么办 win10网络重置了怎么办 win7桌面没有网上邻居怎么办 win7电脑没有网上邻居怎么办 无线网连接受限怎么办 win7账户被锁定怎么办 贷款sdk授权失败怎么办 京东保价发票怎么办 淘宝购物出现质量问题怎么办 淘宝购物降价了怎么办 淘宝购物物流慢怎么办 在淘宝购物退货怎么办 淘宝购物未付款怎么办 淘宝购物余额不足怎么办 淘宝购物漏发货怎么办 京东618无货怎么办 iis默认文档无效怎么办? 购物卡没有磁性怎么办 墙面贴纸没有贴怎么办 车显示电池符号怎么办 遇上北京购物团怎么办 钱柜老是钱不见怎么办 写真顾客退单怎么办 电视不支持投屏怎么办