当前位置: 首页 > 编程日记 > 正文

iOS常用动画 类封装

//这是一个很好的动画封装类  很容易明白很详细  和大家分享
//  CoreAnimationEffect.h
//  CoreAnimationEffect
//
//  Created by VincentXue on 13-1-19.
//  Copyright (c) 2013年 VincentXue. All rights reserved.
//#import /**!  导入QuartzCore.framework**  Example:**  Step.1**      #import "CoreAnimationEffect.h"**  Step.2**      [CoreAnimationEffect animationMoveLeft:your view];* */@interface CoreAnimationEffect : NSObject#pragma mark - Custom Animation/***   @brief 快速构建一个你自定义的动画,有以下参数供你设置.**   @note  调用系统预置Type需要在调用类引入下句**          #import **   @param type                动画过渡类型*   @param subType             动画过渡方向(子类型)*   @param duration            动画持续时间*   @param timingFunction      动画定时函数属性*   @param theView             需要添加动画的view.***/+ (void)showAnimationType:(NSString *)typewithSubType:(NSString *)subTypeduration:(CFTimeInterval)durationtimingFunction:(NSString *)timingFunctionview:(UIView *)theView;#pragma mark - Preset Animation/***  下面是一些常用的动画效果*/// reveal
+ (void)animationRevealFromBottom:(UIView *)view;
+ (void)animationRevealFromTop:(UIView *)view;
+ (void)animationRevealFromLeft:(UIView *)view;
+ (void)animationRevealFromRight:(UIView *)view;// 渐隐渐消
+ (void)animationEaseIn:(UIView *)view;
+ (void)animationEaseOut:(UIView *)view;// 翻转
+ (void)animationFlipFromLeft:(UIView *)view;
+ (void)animationFlipFromRigh:(UIView *)view;// 翻页
+ (void)animationCurlUp:(UIView *)view;
+ (void)animationCurlDown:(UIView *)view;// push
+ (void)animationPushUp:(UIView *)view;
+ (void)animationPushDown:(UIView *)view;
+ (void)animationPushLeft:(UIView *)view;
+ (void)animationPushRight:(UIView *)view;// move
+ (void)animationMoveUp:(UIView *)view duration:(CFTimeInterval)duration;
+ (void)animationMoveDown:(UIView *)view duration:(CFTimeInterval)duration;
+ (void)animationMoveLeft:(UIView *)view;
+ (void)animationMoveRight:(UIView *)view;// 旋转缩放// 各种旋转缩放效果
+ (void)animationRotateAndScaleEffects:(UIView *)view;// 旋转同时缩小放大效果
+ (void)animationRotateAndScaleDownUp:(UIView *)view;#pragma mark - Private API/***  下面动画里用到的某些属性在当前API里是不合法的,但是也可以用.*/+ (void)animationFlipFromTop:(UIView *)view;
+ (void)animationFlipFromBottom:(UIView *)view;+ (void)animationCubeFromLeft:(UIView *)view;
+ (void)animationCubeFromRight:(UIView *)view;
+ (void)animationCubeFromTop:(UIView *)view;
+ (void)animationCubeFromBottom:(UIView *)view;+ (void)animationSuckEffect:(UIView *)view;+ (void)animationRippleEffect:(UIView *)view;+ (void)animationCameraOpen:(UIView *)view;
+ (void)animationCameraClose:(UIView *)view;@end/*******************************************************************************************************************************************************/ //
//  CoreAnimationEffect.m
//  CoreAnimationEffect
//
//  Created by VincentXue on 13-1-19.
//  Copyright (c) 2013年 VincentXue. All rights reserved.
//#import "CoreAnimationEffect.h"#import @implementation CoreAnimationEffect/***  首先推荐一个不错的网站.   http://www.raywenderlich.com*/#pragma mark - Custom Animation+ (void)showAnimationType:(NSString *)typewithSubType:(NSString *)subTypeduration:(CFTimeInterval)durationtimingFunction:(NSString *)timingFunctionview:(UIView *)theView
{/** CATransition**  @see http://www.dreamingwish.com/dream-2012/the-concept-of-coreanimation-programming-guide.html*  @see http://geeklu.com/2012/09/animation-in-ios/**  CATransition 常用设置及属性注解如下:*/CATransition *animation = [CATransition animation];/** delegate**  动画的代理,如果你想在动画开始和结束的时候做一些事,可以设置此属性,它会自动回调两个代理方法.**  @see CAAnimationDelegate    (按下command键点击)*/animation.delegate = self;/** duration**  动画持续时间*/animation.duration = duration;/** timingFunction**  用于变化起点和终点之间的插值计算,形象点说它决定了动画运行的节奏,比如是均匀变化(相同时间变化量相同)还是*  先快后慢,先慢后快还是先慢再快再慢.**  动画的开始与结束的快慢,有五个预置分别为(下同):*  kCAMediaTimingFunctionLinear            线性,即匀速*  kCAMediaTimingFunctionEaseIn            先慢后快*  kCAMediaTimingFunctionEaseOut           先快后慢*  kCAMediaTimingFunctionEaseInEaseOut     先慢后快再慢*  kCAMediaTimingFunctionDefault           实际效果是动画中间比较快.*//** timingFunction**  当上面的预置不能满足你的需求的时候,你可以使用下面的两个方法来自定义你的timingFunction*  具体参见下面的URL**  @see http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/CAMediaTimingFunction_class/Introduction/Introduction.html**  + (id)functionWithControlPoints:(float)c1x :(float)c1y :(float)c2x :(float)c2y;**  - (id)initWithControlPoints:(float)c1x :(float)c1y :(float)c2x :(float)c2y;*/animation.timingFunction = [CAMediaTimingFunction functionWithName:timingFunction];/** fillMode**  决定当前对象过了非active时间段的行为,比如动画开始之前,动画结束之后.*  预置为:*  kCAFillModeRemoved   默认,当动画开始前和动画结束后,动画对layer都没有影响,动画结束后,layer会恢复到之前的状态*  kCAFillModeForwards  当动画结束后,layer会一直保持着动画最后的状态*  kCAFillModeBackwards 和kCAFillModeForwards相对,具体参考上面的URL*  kCAFillModeBoth      kCAFillModeForwards和kCAFillModeBackwards在一起的效果*/animation.fillMode = kCAFillModeForwards;/** removedOnCompletion**  这个属性默认为YES.一般情况下,不需要设置这个属性.**  但如果是CAAnimation动画,并且需要设置 fillMode 属性,那么需要将 removedOnCompletion 设置为NO,否则*  fillMode无效*///    animation.removedOnCompletion = NO;/** type**  各种动画效果  其中除了'fade', `moveIn', `push' , `reveal' ,其他属于似有的API(我是这么认为的,可以点进去看下注释).*  ↑↑↑上面四个可以分别使用'kCATransitionFade', 'kCATransitionMoveIn', 'kCATransitionPush', 'kCATransitionReveal'来调用.*  @"cube"                     立方体翻滚效果*  @"moveIn"                   新视图移到旧视图上面*  @"reveal"                   显露效果(将旧视图移开,显示下面的新视图)*  @"fade"                     交叉淡化过渡(不支持过渡方向)             (默认为此效果)*  @"pageCurl"                 向上翻一页*  @"pageUnCurl"               向下翻一页*  @"suckEffect"               收缩效果,类似系统最小化窗口时的神奇效果(不支持过渡方向)*  @"rippleEffect"             滴水效果,(不支持过渡方向)*  @"oglFlip"                  上下左右翻转效果*  @"rotate"                   旋转效果*  @"push"                    *  @"cameraIrisHollowOpen"     相机镜头打开效果(不支持过渡方向)*  @"cameraIrisHollowClose"    相机镜头关上效果(不支持过渡方向)*//** type**  kCATransitionFade            交叉淡化过渡*  kCATransitionMoveIn          新视图移到旧视图上面*  kCATransitionPush            新视图把旧视图推出去*  kCATransitionReveal          将旧视图移开,显示下面的新视图*/animation.type = type;/** subtype**  各种动画方向**  kCATransitionFromRight;      同字面意思(下同)*  kCATransitionFromLeft;*  kCATransitionFromTop;*  kCATransitionFromBottom;*//** subtype**  当type为@"rotate"(旋转)的时候,它也有几个对应的subtype,分别为:*  90cw    逆时针旋转90°*  90ccw   顺时针旋转90°*  180cw   逆时针旋转180°*  180ccw  顺时针旋转180°*//***  type与subtype的对应关系(必看),如果对应错误,动画不会显现.**  @see http://iphonedevwiki.net/index.php/CATransition*/animation.subtype = subType;/***  所有核心动画和特效都是基于CAAnimation,而CAAnimation是作用于CALayer的.所以把动画添加到layer上.*  forKey  可以是任意字符串.*/[theView.layer addAnimation:animation forKey:nil];
}#pragma mark - Preset Animation+ (void)animationRevealFromBottom:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setType:kCATransitionReveal];[animation setSubtype:kCATransitionFromBottom];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationRevealFromTop:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setType:kCATransitionReveal];[animation setSubtype:kCATransitionFromTop];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationRevealFromLeft:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setType:kCATransitionReveal];[animation setSubtype:kCATransitionFromLeft];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationRevealFromRight:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setType:kCATransitionReveal];[animation setSubtype:kCATransitionFromRight];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationEaseIn:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setType:kCATransitionFade];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationEaseOut:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setType:kCATransitionFade];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[view.layer addAnimation:animation forKey:nil];
}/***  UIViewAnimation**  @see    http://www.cocoachina.com/bbs/read.php?tid=110168**  @brief  UIView动画应该是最简单便捷创建动画的方式了,详解请猛戳URL.* *  @method beginAnimations:context 第一个参数用来作为动画的标识,第二个参数给代理代理传递消息.至于为什么一个使用*                                  nil而另外一个使用NULL,是因为第一个参数是一个对象指针,而第二个参数是基本数据类型.*  @method setAnimationCurve:      设置动画的加速或减速的方式(速度)*  @method setAnimationDuration:   动画持续时间*  @method setAnimationTransition:forView:cache:   第一个参数定义动画类型,第二个参数是当前视图对象,第三个参数是是否使用缓冲区*  @method commitAnimations        动画结束*/+ (void)animationFlipFromLeft:(UIView *)view
{[UIView beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];[UIView setAnimationDuration:0.35f];[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view cache:NO];[UIView commitAnimations];
}+ (void)animationFlipFromRigh:(UIView *)view
{[UIView beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];[UIView setAnimationDuration:0.35f];[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:view cache:NO];[UIView commitAnimations];
}+ (void)animationCurlUp:(UIView *)view
{[UIView beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];[UIView setAnimationDuration:0.35f];[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:view cache:NO];[UIView commitAnimations];
}+ (void)animationCurlDown:(UIView *)view
{[UIView beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];[UIView setAnimationDuration:0.35f];[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:view cache:NO];[UIView commitAnimations];
}+ (void)animationPushUp:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:kCATransitionPush];[animation setSubtype:kCATransitionFromTop];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationPushDown:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:kCATransitionPush];[animation setSubtype:kCATransitionFromBottom];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationPushLeft:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:kCATransitionPush];[animation setSubtype:kCATransitionFromLeft];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationPushRight:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:kCATransitionPush];[animation setSubtype:kCATransitionFromRight];[view.layer addAnimation:animation forKey:nil];
}// presentModalViewController
+ (void)animationMoveUp:(UIView *)view duration:(CFTimeInterval)duration
{CATransition *animation = [CATransition animation];[animation setDuration:duration];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];[animation setType:kCATransitionMoveIn];[animation setSubtype:kCATransitionFromTop];[view.layer addAnimation:animation forKey:nil];
}// dissModalViewController
+ (void)animationMoveDown:(UIView *)view duration:(CFTimeInterval)duration
{CATransition *transition = [CATransition animation];transition.duration =0.4;transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];transition.type = kCATransitionReveal;transition.subtype = kCATransitionFromBottom;[view.layer addAnimation:transition forKey:nil];
}+ (void)animationMoveLeft:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:kCATransitionMoveIn];[animation setSubtype:kCATransitionFromLeft];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationMoveRight:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:kCATransitionMoveIn];[animation setSubtype:kCATransitionFromRight];[view.layer addAnimation:animation forKey:nil];
}+(void)animationRotateAndScaleEffects:(UIView *)view
{[UIView animateWithDuration:0.35f animations:^{/***  @see       http://donbe.blog.163.com/blog/static/138048021201061054243442/**  @param     transform   形变属性(结构体),可以利用这个属性去对view做一些翻转或者缩放.详解请猛戳↑URL.**  @method    valueWithCATransform3D: 此方法需要一个CATransform3D的结构体.一些非详细的讲解可以看下面的URL**  @see       http://blog.csdn.net/liubo0_0/article/details/7452166**/view.transform = CGAffineTransformMakeScale(0.001, 0.001);CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];// 向右旋转45°缩小到最小,然后再从小到大推出.animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.70, 0.40, 0.80)];/***     其他效果:*     从底部向上收缩一半后弹出*     animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0, 1.0, 0.0)];**     从底部向上完全收缩后弹出*     animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 1.0, 0.0, 0.0)];**     左旋转45°缩小到最小,然后再从小到大推出.*     animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.50, -0.50, 0.50)];**     旋转180°缩小到最小,然后再从小到大推出.*     animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.1, 0.2, 0.2)];*/animation.duration = 0.45;animation.repeatCount = 1;[view.layer addAnimation:animation forKey:nil];}completion:^(BOOL finished){[UIView animateWithDuration:0.35f animations:^{view.transform = CGAffineTransformMakeScale(1.0, 1.0);}];}];
}/** CABasicAnimation**  @see https://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CoreAnimation_guide/Articles/KVCAdditions.html**  @brief                      便利构造函数 animationWithKeyPath: KeyPath需要一个字符串类型的参数,实际上是一个*                              键-值编码协议的扩展,参数必须是CALayer的某一项属性,你的代码会对应的去改变该属性的效果*                              具体可以填写什么请参考上面的URL,切勿乱填!*                              例如这里填写的是 @"transform.rotation.z" 意思就是围绕z轴旋转,旋转的单位是弧度.*                              这个动画的效果是把view旋转到最小,再旋转回来.*                              你也可以填写@"opacity" 去修改透明度...以此类推.修改layer的属性,可以用这个类.**  @param toValue              动画结束的值.CABasicAnimation自己只有三个属性(都很重要)(其他属性是继承来的),分别为:*                              fromValue(开始值), toValue(结束值), byValue(偏移值),!                              这三个属性最多只能同时设置两个;*                              他们之间的关系如下:*                              如果同时设置了fromValue和toValue,那么动画就会从fromValue过渡到toValue;*                              如果同时设置了fromValue和byValue,那么动画就会从fromValue过渡到fromValue + byValue;*                              如果同时设置了byValue  和toValue,那么动画就会从toValue - byValue过渡到toValue;**                              如果只设置了fromValue,那么动画就会从fromValue过渡到当前的value;*                              如果只设置了toValue  ,那么动画就会从当前的value过渡到toValue;*                              如果只设置了byValue  ,那么动画就会从从当前的value过渡到当前value + byValue.**                              可以这么理解,当你设置了三个中的一个或多个,系统就会根据以上规则使用插值算法计算出一个时间差并*                              同时开启一个Timer.Timer的间隔也就是这个时间差,通过这个Timer去不停地刷新keyPath的值.!                              而实际上,keyPath的值(layer的属性)在动画运行这一过程中,是没有任何变化的,它只是调用了GPU去*                              完成这些显示效果而已.*                              在这个动画里,是设置了要旋转到的弧度,根据以上规则,动画将会从它当前的弧度专旋转到我设置的弧度.**  @param duration             动画持续时间**  @param timingFunction       动画起点和终点之间的插值计算,也就是说它决定了动画运行的节奏,是快还是慢,还是先快后慢...*//** CAAnimationGroup**  @brief                      顾名思义,这是一个动画组,它允许多个动画组合在一起并行显示.比如这里设置了两个动画,*                              把他们加在动画组里,一起显示.例如你有几个动画,在动画执行的过程中需要同时修改动画的某些属性,*                              这时候就可以使用CAAnimationGroup.**  @param duration             动画持续时间,值得一提的是,如果添加到group里的子动画不设置此属性,group里的duration会统一*                              设置动画(包括子动画)的duration属性;但是如果子动画设置了duration属性,那么group的duration属性*                              的值不应该小于每个子动画中duration属性的值,否则会造成子动画显示不全就停止了动画.**  @param autoreverses         动画完成后自动重新开始,默认为NO.**  @param repeatCount          动画重复次数,默认为0.**  @param animations           动画组(数组类型),把需要同时运行的动画加到这个数组里.**  @note  addAnimation:forKey  这个方法的forKey参数是一个字符串,这个字符串可以随意设置.**  @note                       如果你需要在动画group执行结束后保存动画效果的话,设置 fillMode 属性,并且把*                              removedOnCompletion 设置为NO;*/+ (void)animationRotateAndScaleDownUp:(UIView *)view
{CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * 2];rotationAnimation.duration = 0.35f;rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];scaleAnimation.toValue = [NSNumber numberWithFloat:0.0];scaleAnimation.duration = 0.35f;scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];CAAnimationGroup *animationGroup = [CAAnimationGroup animation];animationGroup.duration = 0.35f;animationGroup.autoreverses = YES;animationGroup.repeatCount = 1;animationGroup.animations =[NSArray arrayWithObjects:rotationAnimation, scaleAnimation, nil];[view.layer addAnimation:animationGroup forKey:@"animationGroup"];
}#pragma mark - Private API+ (void)animationFlipFromTop:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"oglFlip"];[animation setSubtype:@"fromTop"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationFlipFromBottom:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"oglFlip"];[animation setSubtype:@"fromBottom"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationCubeFromLeft:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"cube"];[animation setSubtype:@"fromLeft"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationCubeFromRight:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"cube"];[animation setSubtype:@"fromRight"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationCubeFromTop:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"cube"];[animation setSubtype:@"fromTop"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationCubeFromBottom:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"cube"];[animation setSubtype:@"fromBottom"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationSuckEffect:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"suckEffect"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationRippleEffect:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"rippleEffect"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationCameraOpen:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"cameraIrisHollowOpen"];[animation setSubtype:@"fromRight"];[view.layer addAnimation:animation forKey:nil];
}+ (void)animationCameraClose:(UIView *)view
{CATransition *animation = [CATransition animation];[animation setDuration:0.35f];[animation setFillMode:kCAFillModeForwards];[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];[animation setType:@"cameraIrisHollowClose"];[animation setSubtype:@"fromRight"];[view.layer addAnimation:animation forKey:nil];
}
@end
最后附上动画类封装的两个源文件 传送门:http://download.csdn.net/detail/u012951123/7110913

转载于:https://www.cnblogs.com/songfeixiang/p/3733679.html

相关文章:

规范化制度保障安擎高品质产品

企业的制度规范是公司管理的依据和准则。一套科学完整的管理制度,有利于维护工作秩序,提高工作效率,也可以保证企业的正常运转和职工的合法利益不受侵害。据内部核算,安擎计算机有限公司在2017年十二次月度产品测试中,…

带进度条的ASP无组件断点续传下载代码

<%LANGUAGE"VBSCRIPT" CODEPAGE"936"%><%Option Explicit%><% 带进度条的ASP无组件断点续传下载简介&#xff1a; 1)利用xmlhttp方式 2)无组件 3)异步方式获取&#xff0c;节省服务器资源 4)服务器到服务器的文件传送。(当然&am…

塔式、机架式、刀片式服务器比较

塔式机架式刀片式优点单个成本低&#xff1b;扩展能力和散热能力好&#xff1b;可以配置多路处理器、多根内存、多块硬盘、多个冗余电源和散热风扇相对于塔式大大节省了空间占用&#xff0c;使布线、管理更为简洁&#xff1b;节省了机房托管费用&#xff1b;平衡了性能与空间扩…

Flume-0.9.4数据插入HBase-0.96

来自&#xff1a;http://blog.csdn.net/iam333/article/details/18770977 最近由于业务需要&#xff0c;需要将flume的数据插入HBase-0.96,利用flume的实时日志收集&#xff0c;实现数据的实时存储。正如前文所 述&#xff0c;flume-ng即flume-1.4.0版本和hbase-0.96结合相对比…

卡壳了~~~ 解决了~~~My Site创建成功了.....

没想到解决这个问题如此简单就是把SharePoint Products and Technologies Configuration Wizard运行一遍&#xff0c;一切都修复了&#xff0c;哈哈~~~快下班了&#xff0c;也没过多测试&#xff0c;似乎没有损失什么数据。 转载于:https://www.cnblogs.com/booolee/archive/20…

Linux 配置开机自启 和 修改环境变量

【 操作系统 Centos7 】 一&#xff0c;开机自动启动的配置 1&#xff0c;赋予 /etc/rc.local 的执行权限 > chmod x /etc/rc.local 2&#xff0c;在 /etc/rc.local 在文件末尾编写要执行的脚本 3&#xff0c;注意写在这个文件中的脚本不要使用相对路径 二&#xff0c;环境变…

无线传感器网络WSN技术、协议、距离汇总

技术协议距离WMANIEEE802.16五公里内WLANIEEE802.11几公里内WPAN蓝牙IEEE802.15.4 紫蜂IEEE802.15.110m内

IISApp -a查找对应的AppPool

cmd下运行IISApp -a可以查找出来每个w3wp.exe对应的应用程序池 [name:IISApp To AppPool][tags:IIS] [From AlphaWu.Blog]转载于:https://www.cnblogs.com/AlphaWu/archive/2006/11/27/574390.html

ZKFC服务异常:Parent znode does not exist.

昨天搭建了一套hadoop集群&#xff0c;今天发现两个namenode的zkfc服务起不来&#xff0c;在zkfc日志中发现如下所示的信息&#xff1a;Unable to start failover controller. Parent znode does not exist../bin/zkCli.sh -server master1ls /没有看到/hadoop-ha解决方法&…

数学工具WZgrapher

之前说了mathGV&#xff0c;其实还有一个不错类似软件WZgrapher&#xff0c;不仅可以画函数图&#xff0c;还可以微积分。 截图如下&#xff1a; 转载于:https://www.cnblogs.com/CodeWorkerLiMing/p/3632778.html

用ASP.NET建立一个在线RSS新闻聚合器(3)

显示特定聚合摘要的新闻项   我们面临的下一个任务是创建 DisplayNewsItems.aspx 页面。这个页面会以链接的形式显示所选聚合摘要的新闻项标题&#xff0c;当点击标题时&#xff0c;新闻的内容就会显示在右下部分的框架中。要完成这一任务&#xff0c;我们会面临以下两个主要…

mysql中在表中insert数据时,有重复主键id时,变成update

MySQL 自4.1版以后开始支持INSERT … ON DUPLICATE KEY UPDATE语法 例如&#xff1a; idnamesexage 1kathymale23 2Javerfamale32 3Mikemale19方法一&#xff1a; INSERT INTO kk (id, name,sex) VALUES(1,kara,ssss) ON DUPLICATE KEY UPDATE id1;方法二&#xff1a; REPLACE…

ECS 实例网络带宽

1. 带宽是否独享&#xff1f; 是独享。 2. 带宽单线还是双线&#xff0c;电信还是网通&#xff1f; 多线 BGP&#xff08;中国电信、联通、移动、教育网等&#xff09;接入&#xff0c;确保全国用户访问畅通。 3. 5 Mbps 带宽怎么理解&#xff1f; 5 Mbps 带宽是指带宽总出口是…

bootstrap-less源码分析:容器

流体容器和固定容器的公共样式 .container-fixed(gutter: grid-gutter-width) {//grid-gutter-width为默认取值&#xff0c;值为30px margin-right: auto; margin-left: auto; padding-left: floor((gutter / 2));//向下取整 padding-right: ceil((gutter / 2)); &:extend(…

Windows7防火墙服务无法启用怎么办

Windows7防火墙服务无法启用怎么办 点击windows 7控制面板中防火墙的“推荐配置”没有反应&#xff0c;打开“服务”&#xff0c;无法启动windows firewall&#xff0c;并报错。问题&#xff1a; 1.点击windows 7控制面板中防火墙的“推荐配置”没有反应 2.打开“服务”&#x…

在首次发布三周之后,MLflow迎来了0.2版本

在今年的SparkAI峰会上&#xff0c;MLflow团队推出了MLflow&#xff0c;一个开源的用于简化机器学习生命周期的平台。从首次发布到现在的三周时间里&#xff0c;已经有很多数据科学家和工程师对使用MLflow和为MLflow贡献代码感兴趣。MLFlow的GitHub仓库已经有180个分支&#xf…

CoCreateInstance 出错 ,返回 -2147221164 CLASS_NOT_REGISTERED ,原因

今天发现有台机子执行 CoCreateInstance 总是不成功&#xff0c;而在其他的很多机子上是没有问题的。 追了半天发现这台机子的注册表权限不对。HKEY_CLASSES_ROOT的权限只有Everyone&#xff0c;少了System&#xff0c;以及其他的几个。 加上System之后就可以了。不知道Everyon…

bootstrap-less源码分析:行和列

一、行 grid.less文件中有关行的全部源码 .row { .make-row();//调用 }//进mixin/grid.less找到行的定义 .make-row(gutter: grid-gutter-width) { margin-left: ceil((gutter / -2));//负的槽宽的一半 -15 margin-right: floor((gutter / -2)); &:extend(.clearfix all…

博客园,我来了~

希望在这里留下我美好的回忆~ 转载于:https://www.cnblogs.com/wangzhigang/p/3638400.html

ARE YOU THE ONE?

总觉得&#xff0c;特定环境下&#xff0c;他或者她&#xff0c;这个称呼是有一些暧昧的。比如我的前同事M&#xff0c;跟她男朋友刚相亲认识的时候&#xff0c;跟我说起&#xff0c;总是那个人那个人的称呼&#xff0c;一副局外人的架势。后来&#xff0c;他们熟悉了&#xff…

Windows和Linux的编译理解

Windows一般编译出来的x86的软件&#xff0c;就是只能在x86的系统上才能运行&#xff0c;同理&#xff0c;在x64系统上也是一样的道理。 Linux利用gcc编译器编译&#xff0c;可以在Linux上面运行&#xff0c;但是想要在嵌入式系统上运行的话&#xff0c;需要在Linux上安装相应的…

安卓环境搭建 unable to access Android SDK add-on list解决方案

选择Setup Proxy 选择Manual proxy configuration 设置Host name 为&#xff1a;mirrors.neusoft.edu.cn 保持Port number 为&#xff1a;80 确定 参考博客&#xff1a;https://blog.csdn.net/qq_35892584/article/details/109746886?utm_mediumdistribute.pc_relevant.…

Git使用笔记(一)

今天第一次使用Git&#xff0c;在本地和CSDN Code进行代码同步。鉴于“好记性不如烂笔头”的经验教训&#xff0c;特把步骤记录下来。 准备工作&#xff1a; 1. 在CSDN&#xff08;或者Github&#xff09;上注册一个帐号&#xff0c;然后创建一个Repository。记录下Repository的…

ASP.NET 2.0站点登录、导航与权限管理

(一)登录 asp.net 2.0中&#xff0c;新增了许多新的功能和控件。其中&#xff0c;新增的登陆控件可谓使得WEB应用的设计更加得心应手。什么是登陆控件呢&#xff1f;就是我们平常在WEB应用中经常要用到的用户注册&#xff0c;登陆&#xff0c;忘记密码&#xff0c;登陆后根据权…

Android 中一些常用类的常用方法(Math、Random、Color、Paint、Canvas、Bitmap、BitmapFactory)...

1.java.lang.Math类常用的常量和方法&#xff1a; Math.PI 记录的圆周率 Math.E 记录e的常量 Math.abs 求绝对值 Math.sin 正弦函数 Math.asin 反正弦函数 Math.cos 余弦函数 Math.acos 反余弦函数 Math.tan 正切函数 Math.atan 反正切函数 Math.atan2 商的反正切函数 Math.toD…

效果很好的asp.net的数据库访问模型(优化,封装一体化)

效果很好的asp.net的数据库访问模型&#xff08;优化&#xff0c;封装一体化&#xff09; 非常有效的数据库/配置文件访问模型。成功使用在几万流量的网站上。任何建议欢迎大家交流。 在使用SqlCommand对象过程中&#xff0c;我们需要分配Connection对象。 通常&#xff0c;对于…

【技巧——windows】直接登陆到桌面,免去输入密码

关于这个问题其实我很早之前就研究过&#xff0c;只是一直都是弄一次就不管了&#xff0c;下次就忘记怎么弄了&#xff0c;又去查&#xff0c;现在就写个笔记吧。 win8/8.1 在开始的界面输入netplwiz&#xff0c;或者点击winr打开运行&#xff0c;输入netplwiz&#xff0c;然后…

虚商烦恼多?不在怕的!你距离享受高效虚商控制台只差一步的距离

摘要&#xff1a;虚商烦恼多&#xff1f;不在怕的&#xff01;你距离享受高效虚商控制台只差一步的距离虚商自助服务平台 vco.console.aliyun.com/原文链接本文为云栖社区原创内容&#xff0c;未经允许不得转载