码迷,mamicode.com
首页 > 移动开发 > 详细

iOS页面切换动画实现方式。

时间:2015-10-23 11:55:24      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

iOS页面切换动画实现方式。

  1.使用UIView animateWithDuration:animations:completion方法

  Java代码
  

  1. [UIView animateWithDuration:0.2f animations:^{
  2.   detail.view.frame = CGRectMake(0, 0, detail.view.frame.size.width, detail.view.frame.size.height);
  3.   } completion:^(BOOL finished) {
  4.   UITableViewCell *cell = [articleTable cellForRowAtIndexPath:idx];
  5.   cell.backgroundColor = [UIColor clearColor];
  6.   }];
复制代码


  2.使用UIView beginAnimations:context和UIView commitAnimations方法

  Java代码

  1.   [UIView beginAnimations:nil context: nil];
  2.   [UIView setAnimationDuration:1.0];
  3.   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//指定动画曲线
  4.   [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];//指定动画方式为卷帘向下,类似的动画切换方式有CurlUp、FlipFromLeft、FlipFromRight,对应Apple Developer Documents中的枚举结构如下
  5.   //UIViewAnimationTransition
  6.   //Specifies a transition to apply to a view in an animation block.
  7.   //typedef enum {
  8.   // UIViewAnimationTransitionNone,
  9.   // UIViewAnimationTransitionFlipFromLeft,
  10.   // UIViewAnimationTransitionFlipFromRight,
  11.   // UIViewAnimationTransitionCurlUp,
  12.   // UIViewAnimationTransitionCurlDown,
  13.   //} UIViewAnimationTransition;
  14.   //要动画改变的属性
  15.   self.view.alpha = 0.0;//动画改变透明度
  16.   self.view.frame = CGRectMake(10, 10, 50, 50);//动画将视图改变到指定位置指定大小
  17.   [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
  18.   [UIView commitAnimations];//提交动画
复制代码


  3.使用QuartzCore框架中的CATransition

  Java代码
 

  1.  CATransition *animation = [CATransition animation];
  2.   animation.delegate = self;
  3.   animation.duration = kDuration;
  4.   animation.timingFunction = UIViewAnimationCurveEaseInOut;//动画的开始与结束的快慢
  5.   animation.type = kCATransitionFade;//指定动画方式为Fade渐隐消去、类似还有kCATransitionPush、kCATransitionReveal、kCATransitionMoveIn、@"cube"、@"suckEffect"、@"oglFlip"、@"rippleEffect"、@"pageCurl"、@"pageUnCurl"、@"cameraIrisHollowOpen"、@"cameraIrisHollowClose"等,
  6.   //pageCurl 向上翻一页
  7.   //pageUnCurl 向下翻一页
  8.   //rippleEffect 滴水效果
  9.   //suckEffect 收缩效果,如一块布被抽走
  10.   //cube 立方体效果
  11.   //oglFlip 上下翻转效果
  12.   //cameraIrisHollowOpen 相机打开效果
  13.   //cameraIrisHollowClose 相机关闭效果
  14.   Apple Developer Documents中介绍如下
  15.   //Common Transition Types
  16.   //These constants specify the transition types that can be used with the type property.
  17.   //NSString * const kCATransitionFade;
  18.   //NSString * const kCATransitionMoveIn;
  19.   //NSString * const kCATransitionPush;
  20.   //NSString * const kCATransitionReveal;
  21.   animation.subtype = kCATransitionFromLeft;//指定动画进行方向从左边开始,类似还有kCATransitionFromBottom、kCATransitionFromRight、kCATransitionFromTop,Apple Developer Documents中介绍如下
  22.   //Common Transition Subtypes
  23.   //These constants specify the direction of motion-based transitions. They are used //with the subtype property.
  24.   //NSString * const kCATransitionFromRight;
  25.   //NSString * const kCATransitionFromLeft;
  26.   //NSString * const kCATransitionFromTop;
  27.   //NSString * const kCATransitionFromBottom;
  28.   [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
  29.   [[self.view layer] addAnimation:animation forKey:@"animation"];
复制代码



原文链接:http://www.apkbus.com/android-131034-1-1.html

iOS页面切换动画实现方式。

标签:

原文地址:http://www.cnblogs.com/ycblog/p/4903899.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!