IOS中各种动画特效的实现

第一类动画特效:
这类特效有四种,在UIView中就可以实现,分别为CurlDown,CurlUp,FilpFromLeft,FilpFromRight。在视图切换之前设置UIView,如下:

    [UIView beginAnimations:@"Animation" context:nil];

    [UIView setAnimationDuration:0.5];//设置动画持续时间;

    [UIView setAnimationDelegate:self];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

接下来设置动画特效,有四种特效可供选择:

 

[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionFilpFromLeft forView:self.view cache:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionFilpFromRight forView:self.view cache:YES];

之后就可以切换view了,最后执行动画:

 

[UIView commitAnimations];


第二类动画特效:

这类动画特效需要用到QuartzCore.framework,单击工程,点击Build Phases,找到Link Binary With Libraries,点击下面的+号,找到QuartzCore.framework添加即可。

同样,在view切换之前需要做一些设置:

 

    CATransition *animation = [CATransition animation]; //声明动画对象;

    animation.delegate = self;

    animation.duration = kDuration;//设置动画持续时间;

    animation.timingFunction = UIViewAnimationCurveEaseInOut;

然后就可以选择动画类型,大概有十二种动画:

 

animation.type = kCATransitionFade;

animation.type = kCATransitionPush;

animation.type = kCATransitionReveal;

animation.type = kCATransitionMoveIn;

animation.type = @"cube";

animation.type = @"suckEffect";

animation.type = @"oglFlip";

animation.type = @"rippleEffect";

animation.type = @"pageCurl";

animation.type = @"pageUnCurl";

animation.type = @"cameraIrisHollowOpen";

animation.type = @"cameraIrisHollowClose";

任选其中一种。同时也可以设置animation的subtype,用以设置动画运行的方向,如:

 

animation.subtype = kCATransitionFromLeft;

animation.subtype = kCATransitionFromBottom;

animation.subtype = kCATransitionFromRight;

animation.subtype = kCATransitionFromTop;

之后是切换view,最后还要添加一句代码:

 

[[self.view layer] addAnimation:animation forKey:@"animation"];


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值