iOS动画
iOS页面切换动画实现方式。1.使用UIView animateWithDuration:animations:completion方法
; cell.backgroundColor = ; }];
2.使用UIView beginAnimations:context和UIView commitAnimations方法
;;;//指定动画曲线;//指定动画方式为卷帘向下,类似的动画切换方式有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);//动画将视图改变到指定位置指定大小;;//提交动画
3.使用QuartzCore框架中的CATransition
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;;[ addAnimation:animation forKey:@"animation"];
页:
[1]