iOS页面切换动画实现方式。
1.使用
UIView animateWithDuration:animations:completion方法
[UIView animateWithDuration:0.2f animations:^{
detail.view.frame = CGRectMake(0, 0, detail.view.frame.size.width, detail.view.frame.size.height);
} completion:^(BOOL finished) {
UITableViewCell *cell = [articleTable cellForRowAtIndexPath:idx];
cell.backgroundColor = [UIColor clearColor];
}];
2.使用UIView beginAnimations:context和UIView commitAnimations方法
[UIView beginAnimations:nil context: nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//指定动画曲线
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];//指定动画方式为卷帘向下,类似的动画切换方式有CurlUp、FlipFromLeft、FlipFromRight,对应Apple Developer Documents中的枚举结构如下
//UIViewAnimationTransition
//Specifies a transition to apply to a view in an animation block.
//typedef enum {
// UIViewAnimationTransitionNone,
// UIViewAnimationTransitionFlipFromLeft,
// UIViewAnimationTransitionFlipFromRight,
// UIViewAnimationTransitionCurlUp,
// UIViewAnimationTransitionCurlDown,
//} UIViewAnimationTransition;
//要动画改变的属性
self.view.alpha = 0.0;//动画改变透明度
self.view.frame = CGRectMake(10, 10, 50, 50);//动画将视图改变到指定位置指定大小
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
[UIView commitAnimations];//提交动画
3.使用QuartzCore框架中的CATransition
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = kDuration;
animation.timingFunction = UIViewAnimationCurveEaseInOut;//动画的开始与结束的快慢
animation.type = kCATransitionFade;//指定动画方式为Fade渐隐消去、类似还有kCATransitionPush、kCATransitionReveal、kCATransitionMoveIn、@"cube"、@"suckEffect"、@"oglFlip"、@"rippleEffect"、@"pageCurl"、@"pageUnCurl"、@"cameraIrisHollowOpen"、@"cameraIrisHollowClose"等,
//pageCurl 向上翻一页
//pageUnCurl 向下翻一页
//rippleEffect 滴水效果
//suckEffect 收缩效果,如一块布被抽走
//cube 立方体效果
//oglFlip 上下翻转效果
//cameraIrisHollowOpen 相机打开效果
//cameraIrisHollowClose 相机关闭效果
Apple Developer Documents中介绍如下
//Common Transition Types
//These constants specify the transition types that can be used with the type property.
//NSString * const kCATransitionFade;
//NSString * const kCATransitionMoveIn;
//NSString * const kCATransitionPush;
//NSString * const kCATransitionReveal;
animation.subtype = kCATransitionFromLeft;//指定动画进行方向从左边开始,类似还有kCATransitionFromBottom、kCATransitionFromRight、kCATransitionFromTop,Apple Developer Documents中介绍如下
//Common Transition Subtypes
//These constants specify the direction of motion-based transitions. They are used //with the subtype property.
//NSString * const kCATransitionFromRight;
//NSString * const kCATransitionFromLeft;
//NSString * const kCATransitionFromTop;
//NSString * const kCATransitionFromBottom;
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
[[self.view layer] addAnimation:animation forKey:@"animation"];
分享到:
相关推荐
- [iOS动画和特效(一)UIView动画和CoreAnimation](http://liuyanwei.jumppo.com/2015/10/30/iOS-Animation-UIViewAndCoreAnimation.html) - [iOS动画和特效(二)UIKit力学行为]...
实用,易用的 iOS 动画集合库.zip,在swift中简化ios动画的库。
iOS动画库的精选列表
IOS动画核心技术与案例实战
A_GUIDE_TO_IOS_ANIMATION_2.0.pdf )中文高清彩板,Kitten的iOS 动画学习手册2.0,从动画基础开始学习kitten动画
iOS动画效果集 CA360 ,CA360 包含 iOS 上的 Core Animation 的非常多的示例。
又一个全新的 iOS 动画引擎,Demo 和使用场景很不错。.zip,Elegant transition library for iOS & tvOS
iOS动画-animation1:博客相关代码
ios动画的源码总结,封装了我们常见的动画内容.
iOS动画的测试代码, 写了一个测试的小例子, 可以理解iOS中动画的行为
第四章iOS动画关键帧动画 深入学习关键帧动画 中文学习iOS动画很好的参考文档
ios 动画 时钟 波浪
iOS动画 - 几种特殊的layer动画
iOS 动画菜单 ContextMenu.iOS ,ContextMenu.iOS是一款效果很好的动画菜单,支持高度的自定义,适用于多种类型例如社交类应...
iOS动画系列第六章中文文档 深入学习iOS动画
iOS核心动画高级技巧iOS核心动画高级技巧iOS核心动画高级技巧iOS核心动画高级技巧iOS核心动画高级技巧
iOS动画高级讲解
iOS动画--视频 很犀利的翻译文档 系列学习iOS动画
iOS 动画队列-仿映客刷礼物效果