轉-- iOS 30多個iOS常用動畫,帶詳細注釋

//
//  CoreAnimationEffect.h
//  CoreAnimationEffect
//
//  Created by VincentXue on 13-1-19.
//  Copyright (c) 2013年 VincentXue. All rights reserved.
//#import <Foundation/Foundation.h>/**!  導入QuartzCore.framework**  Example:**  Step.1**     #import <QuartzCore/QuartzCore.h>**  Step.2**      [CoreAnimationEffect animationMoveLeft:your view];*  */@interface CoreAnimationEffect : NSObject#pragma mark - Custom Animation/***   @brief 快速構建一個你自定義的動畫,有以下參數供你設置.**   @note  調用系統預置Type需要在調用類引入下句**          #import <QuartzCore/QuartzCore.h>**   @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 <QuartzCore/QuartzCore.h>@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

  

轉載于:https://www.cnblogs.com/wangshengjia/p/4207961.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/273460.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/273460.shtml
英文地址,請注明出處:http://en.pswp.cn/news/273460.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java中abstract與interface

抽象類&#xff08;abstract class&#xff09;的特點&#xff1a; 1.抽象類、抽象方法都必須使用abstract修飾。 2.抽象類中&#xff0c;可以有非抽象方法&#xff0c;甚至可以是沒有任何方法或變量的空類。 對于抽象類中不定義抽象方法的用意在于&#xff1a;使該類不能被創建…

按位與、或、異或等運算方法

按位與運算符&#xff08;&&#xff09; 參加運算的兩個數據&#xff0c;按二進制位進行“與”運算。 運算規則&#xff1a;0&00; 0&10; 1&00; 1&11; 即&#xff1a;兩位同時為“1”&#xff0c;結果才為“1”&#xff0c;否則為0 例如&#xff1…

JavaScript驗證

<script type"text/javascript"> /*密碼*/ function password() { var password document.getElementById("password").value; var ts document.getElementById("tsPassword"); if (password.length >…

mysql數據庫根據上傳的經緯度計算距離

select 6371.393*ACOS(COS(RADIANS(latitude))*COS(RADIANS(47.02))*COS(RADIANS(longitude)-RADIANS(114.100))SIN(RADIANS(latitude))*SIN(RADIANS(47.02))) as distancefrom location

emacs配置

; 指針顏色設置為白色(set-cursor-color "white");; 鼠標顏色設置為白色(set-mouse-color "white") ;; 從color-theme中獲取;; 網上下載color-theme.el&#xff0c;放到加載路徑(&#xff0f;usr/share/emacs/site-lisp )下;; M-x color-theme-select,鼠標…

自然連接(NATURAL JOIN)

自然連接&#xff08;NATURAL JOIN&#xff09;是一種特殊的等價連接&#xff0c;它將表中具有相同名稱的列自動進行記錄匹配。自然連接不必指定任何同等連接條件。圖9.9給出了典型的自然連接示意圖。 圖9.9 自然連接 自然連接自動判斷相同名稱的列&#xff0c;而后形成匹配。…

iis express8 自動關閉

引用&#xff1a;http://www.cnblogs.com/chunCui/p/3522619.html 問題&#xff1a;最近使用vs2013開發個web &#xff0c; 每次調試結束時iis express 8 也會自動關閉 解決方法&#xff1a;web項目-屬性-web-調試器-只選中ASP.Net就可以了 轉載于:https://www.cnblogs.com/qqq…

自連接

9.3 表的連接類型 9.3.1 自連接 自連接是指表與其自身進行連接&#xff0c;這就需要用到前面介紹的表別名。下面通過一個具體實例來講解自連接的應用。 實例5 自連接的使用方法 查詢成績中存在不及格課程的學生的姓名、所在系、所有的課程及成績信息。如果采用前面介紹的…

從此記錄

從此記錄工作、學習、生活的那些事兒&#xff01;轉載于:https://www.cnblogs.com/alwaysjava/p/4221362.html

LIKE運算符

6.5 使用LIKE進行模糊查詢 當只知道部分字符串時&#xff0c;可使用LIKE運算符來查詢數據庫&#xff0c;找出與其相關的整個字符串。因此&#xff0c;當把關鍵字LIKE用在WHERE子句中時&#xff0c;可以比較兩個字符串的部分匹配。當對字符串內容有些印象&#xff0c;但并不知…

AND運算符

6.2 組合查詢條件 在前一章提到的WHERE子句進行查詢時&#xff0c;WHERE子句后面的搜索條件只是單一的。實際上&#xff0c;可以通過布爾運算符AND和OR&#xff0c;將多個單獨的搜索條件結合在一個WHERE子句中&#xff0c;形成一個復合的搜索條件。當對復合搜索條件求值時&a…

Cron表達式【一】

Cron表達式【一】 Cron表達式被用來配置CronTrigger實例。 Cron表達式是一個由 7個子表達式組成的字符串。每個子表達式都描述了一個單獨的日程細節。這些子表達式用空格分隔&#xff0c;分別表示&#xff1a; 1. Seconds 秒 2. Minutes 分鐘 3. Hours 小時 4. Day-of-Month 月…

OR運算符

6.2.2 OR運算符 OR運算符表示“或”的關系。當可能有多個條件為True&#xff0c;但只要有一個為True就滿足搜索要求時&#xff0c;可以使用OR運算符來組合搜索條件。OR在結合兩個布爾表達式時&#xff0c;只要其中一個條件為True時&#xff0c;便傳回True。OR運算符的真值表…

Java基礎---網絡編程

第一講 概述 1、網絡模型&#xff1a;OSI參考模型和TCP/IP參考模型 圖示&#xff1a; 一般來說開發處于傳輸層和網際層&#xff0c;應用層為&#xff1a;FTP和HTTP協議等&#xff0c;傳輸層為&#xff1a;UDP和TCP等&#xff0c;網際層為&#xff1a;IP。 通常用戶操作的是…

AND、OR運算符的組合使用

6.2.3 AND、OR運算符的組合使用 在WHERE子句中&#xff0c;通過AND、OR運算符可以同時連接多個條件&#xff0c;當然AND、OR運算符也可以同時使用。但是當AND、OR運算符同時存在時&#xff0c;其優先級如何確定呢&#xff1f;與大多數語言一樣&#xff0c;SQL語言認為AND運算…

Nginx配置指定媒體類型文件強制下載

由于業務需要&#xff0c;在點擊顯示鏈接&#xff08;如www.xxx.com/2015-01-15/xxx.png&#xff09;顯示媒體資源&#xff08;如圖片、視頻、音頻、文檔&#xff09;&#xff0c;而在點擊下載鏈接&#xff08;如www.xxx.com/2015-01-15/xxx.png?downloadtrue&#xff09;請求…

IN運算符的使用

6.3 IN運算符 在查詢中&#xff0c;有時只要滿足多個條件中的一個條件即可&#xff0c;如查詢地址在北京、上海或者重慶的學生信息&#xff0c;這時候可以使用IN運算符。 6.3.1 IN運算符的使用 IN運算符允許根據一行記錄中&#xff0c;是否有一列包括在一系列值之中&#…

app后端設計(php)

來源&#xff1a;http://blog.csdn.net/column/details/mobilebackend.html?page1 做了3年app相關的系統架構&#xff0c;api設計&#xff0c;先后在3個創業公司中工作&#xff0c;經歷過手機網頁端&#xff0c;android客戶端&#xff0c;iphone客戶端&#xff0c;現在從事日p…

NOT運算符與運算符

6.4.2 NOT運算符與<>運算符 對于簡單的條件查詢&#xff0c;NOT運算符與<>運算符的功能幾乎沒有什么區別&#xff0c;那么NOT運算符的優勢體現在哪里呢&#xff1f;答案是它可以與其他運算符組合使用&#xff0c;這一點是<>運算符所不能實現的。在6.4.1節已…

bootstrap-wysiwyg 結合 base64 解碼 .net bbs 圖片操作類 (三) 圖片裁剪

官方的例子 是 長方形的。 我這里 用于 正方形的頭像 所以 做如下 修改 #preview-pane .preview-container {width: 73px;height: 73px;overflow: hidden;} 可惜很莫名奇妙的是 有的時候 他自動把圖片 變小了&#xff0c;而且針對的都是 小圖&#xff0c;大圖 都顯示正常 發現…