0
点赞
收藏
分享

微信扫一扫

ios 动画详解


实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制,

第一种是UIView,UIView方式可能在低层也是使用CATransition进行了封装,它只能用于一些简单的、常用的效果展现,这里写一个常用的示例代码,供大家参考。

1.使用UIView类函数实现:

nFlipFromLeft, 向左转动

nFlipFromRight, 向右转动

nCurlUp, 向上翻动

nCurlDown, 向下翻动

beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.5f]; //动画时长
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; //给视图添加过渡效果
//在这里写你的代码.
[UIView commitAnimations]; //提交动画

2.使用CATransition对象来实现:

CATransition比较强大,一般可以使用CATransition模拟UIView的动画。

   


CATransition *animation = [CATransition animation];
 animation.delegate = self;
 animation.duration = 0.5f; //动画时长
 animation.timingFunction = UIViewAnimationCurveEaseInOut;
 animation.fillMode = kCAFillModeForwards;
 animation.type = @”cube”; //过度效果
 animation.subtype = @”formLeft”; //过渡方向
 animation.startProgress = 0.0 //动画开始起点(在整体动画的百分比)
 animation.endProgress = 1.0;  //动画停止终点(在整体动画的百分比)
 animation.removedOnCompletion = NO;
 [self.view.layer addAnimation:animation forKey:@"animation"];








cameraIris








cube








fade (kCATransitionFade)








moveIn (kCATransitionMoveIn)








oglFlip








pageCurl








pageUnCurl








push (kCATransitionPush)








reveal (kCATransitionReveal)








rippleEffect








suckEffect



举报

相关推荐

0 条评论