iOS - CATransition (过渡动画)

简介

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"];
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值