iOS 转场动画
时间:2014-05-28 00:39:11
收藏:0
阅读:282
Inherits from | |
Conforms to | |
Framework |
/System/Library/Frameworks/QuartzCore.framework |
Availability |
Available in iOS 2.0 and
later. |
Declared in |
CAAnimation.h |
CATransition类实现层的转场动画。你可以从一组预定义的转换或者通过提供定制的CIFilter实例来指定转场效果。
- //定义个转场动画
- CATransition *animation = [CATransition animation];
- //转场动画持续时间
- animation.duration = 0.2f;
- //计时函数,从头到尾的流畅度???
- animation.timingFunction=UIViewAnimationCurveEaseInOut;
- //转场动画类型
- animation.type = kCATransitionReveal;
- //转场动画将去的方向
- animation.subtype = kCATransitionFromBottom;
- //动画时你需要的实现
- self.tabBarController.tabBar.hidden = YES;
- //添加动画 (转场动画是添加在层上的动画)
- self.tabBarController.tabBar.layer addAnimation:animation forKey:@"animation"];
说明:
duration:动画持续的时长。
timingFunction:没明白(谁明白的说明一下吧)
type:转场动画的类型。如果在一个自定义的转场动画中指定的过滤器属性,此属性将被忽略。
type共有四种类型:
NSString * const kCATransitionFade;//逐渐消失 NSString * const kCATransitionMoveIn;//移入 NSString * const kCATransitionPush;//平移(暂且这么称呼吧) NSString * const kCATransitionReveal;//显露
默认类型为kCATransitionFade。
subtype:转场动画将要去往的方向。
subtpye有四种类型:
NSString * const kCATransitionFromRight; NSString * const kCATransitionFromLeft; NSString * const kCATransitionFromTop; NSString * const kCATransitionFromBottom;
默认方向是nil。
[self.tabBarController.tabBar.layer addAnimation:animation forKey:@"animation"];
转场动画是添加给layer的!
以下几种转场动画调用的苹果的私有API,注意咯,小心用了之后被苹果打回来。
- switch (btn.tag) {
- case 0:
- animation.type = @"cube";//---立方体
- break;
- case 1:
- animation.type = @"suckEffect";//103 吸走的效果
- break;
- case 2://前后翻转效果
- animation.type = @"oglFlip";//When subType is "fromLeft" or "fromRight", it‘s the official one.
- break;
- case 3:
- animation.type = @"rippleEffect";//110波纹效果
- break;
- case 4:
- animation.type = @"pageCurl";//101翻页起来
- break;
- case 5:
- animation.type = @"pageUnCurl";//102翻页下来
- break;
- case 6:
- animation.type = @"cameraIrisHollowOpen ";//107//镜头开
- break;
- case 7:
- animation.type = @"cameraIrisHollowClose ";//106镜头关
- break;
- default:
- break;
- }
评论(0)