地图程序那样的Curl效果分享

来源:互联网 发布:linux mtine ctime 编辑:程序博客网 时间:2024/06/08 07:33
看了很多例子的CurlUp和CurlDown,都是翻页效果,没有像地图那样翻到一半停下的,偶然在网上看到了方法,自己做了一个例子,不敢独享,拿出来大家看一下。
关键代码如下:
复制代码
  1. - (IBAction)curlUp{
  2.     NSLog(@"Curl");
  3.     // Curl the image up or down
  4.     CATransition *animation = [CATransition animation];
  5.     [animation setDelegate:self];
  6.     [animation setDuration:0.35];
  7.     [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
  8.     if (!curled){
  9.         animation.type = @"pageCurl";
  10.         animation.fillMode = kCAFillModeForwards;
  11.         animation.endProgress = 0.58;
  12.     } else {
  13.         animation.type = @"pageUnCurl";
  14.         animation.fillMode = kCAFillModeBackwards;
  15.         animation.startProgress = 0.42;
  16.     }
  17.     [animation setRemovedOnCompletion:NO];
  18.     [view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
  19.     
  20.     [view addAnimation:animation forKey:@"pageCurlAnimation"];
  21.     
  22.     // Disable user interaction where necessary
  23.     if (!curled) {
  24.         
  25.     } else {
  26.         
  27.     }
  28.     
  29.     curled = !curled;
  30. }
[ 此帖被gagaga在2009-12-07 17:18重新编辑 ]
图片:屏幕快照 2009-12-07 下午04.24.18.png