简介
CAAnimation 的子类,主要用于做过渡动画、转场动画等。
属性
属性 | 解释 |
---|---|
type | 表示过渡效果,公开 API 有四种 kCATransitionFade 渐变 kCATransitionMoveIn 进入覆盖 kCATransitionPush 推出 kCATransitionReveal 揭露离开 还有一些私有API的动画类型,效果很炫酷,不过不推荐使用。比如"cube", “suckEffect”, “rippleEffect”, “pageCurl”, “pageUnCurl”, “oglFlip”, “cameraIrisHollowOpen”, “cameraIrisHollowClose”, “spewEffect”,“genieEffect”,“unGenieEffect”,“twist”,“tubey”,“swirl”,“charminUltra”, “zoomyIn”, “zoomyOut”, "oglApplicationSuspend"等等。 注:kCATransitionFade 不支持Subtype |
subtype | 表示过渡方向,有四种 kCATransitionFromRight 从右侧进入 kCATransitionFromLeft 从左侧进入 kCATransitionFromTop 从顶部进入 kCATransitionFromBottom 从底部进入 |
startProgress | 动画起点(在整体动画的百分比) |
endProgress | 动画终点(在整体动画的百分比) |
实践
转场动画
self.animationView = [[UIView alloc]init];
self.animationView.frame = CGRectMake(200, kHeight/2-50, 50, 50);
self.animationView.backgroundColor = [UIColor greenColor];
[self.view addSubview:self.animationView];
CATransition *anima = [CATransition animation];
anima.type = kCATransitionPush;
anima.subtype = kCATransitionFromRight;
anima.duration = 1.0f;
[self.animationView.layer addAnimation:anima forKey:@"transitionAnimation"];