三种动画
CGAffineTransform(CoreGraphics.framework)
//UILabel *animateLabel;
animateLabel.transform=CGAffineTransformConcat(CGAffineTransformConcat(CGAffineTransformMakeTranslation(0, 0), CGAffineTransformMakeScale(0, 0)), CGAffineTransformMakeRotation(1));
//CGAffineTransformMakeTranslation:偏移量CGAffineTransformMakeScale:伸缩量CGAffineTransformMakeRotation:角度值
1、UIView Animation
[UIView beginAnimations:@"animationID"context:nil];//开始动画
[UIView setAnimationDuration:1.5f];//设定动画持续时间
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
//UIButton *theButton = (UIButton *)sender;
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUpforView:self.viewcache:YES];//动画
/*setAnimationTransition:
UIViewAnimationTransitionCurlUp;//从下到上
UIViewAnimationTransitionCurlDown;//从上到下
UIViewAnimationTransitionFlipFromLeft;//从左到右
UIViewAnimationTransitionFlipFromRight;//从右到左
*/
[self.viewexchangeSubviewAtIndex:1withSubviewAtIndex:0];
[UIViewcommitAnimations];//动画结束
2、CATransition(QuartzCore.framework)
//BOOL isHalfAnimation;
//CATransition *lastAnimation;
CATransition *animation=[CATransition animation];
animation.delegate = self;
animation.duration = 0.5f ;//动画时间
animation.timingFunction = UIViewAnimationCurveEaseInOut;//先慢后快
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
//各种组合,系统自带.
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:animation forKey:@"animationID"];
self.lastAnimation = animation;
for (int i = 0; i < [self.view.subviews count]; i++) {
[[self.view.subviews objectAtIndex:i] setUserInteractionEnabled:NO];
}
isHalfAnimation = YES;
Public API//各种动画效果
//各种组合,系统自带.
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromRight;
//各种动画效果
/*
kCATransitionFade; //渐渐消失
kCATransitionMoveIn; //覆盖进入
kCATransitionPush;//推出
kCATransitionReveal; //与Move相反
*/
/*
kCATransitionFromRight;
kCATransitionFromLeft;
kCATransitionFromTop;
kCATransitionFromBottom;
*/
3、🍎Private API//各种动画效果
animation.type = @"cube";
//各种动画效果
/*
pageCurl;//上翻页
pageUnCur;//下翻页
cube;//盒子从下到上翻转
suckEffect;//三角,左上角飞出
oglFlip;//上下翻转
rippleEffect;//水波抖动
cameraIris/cameraIrisHollowOpen/cameraIrisHollowClose (镜头快门,这一组动画是有效果,只是很难看,不建议使用)
而以下则为黑名单:
spewEffect: 新版面在屏幕下方中间位置被释放出来覆盖旧版面.
- genieEffect: 旧版面在屏幕左下方或右下方被吸走, 显示出下面的新版面 (阿拉丁灯神?).
- unGenieEffect: 新版面在屏幕左下方或右下方被释放出来覆盖旧版面.
- twist: 版面以水平方向像龙卷风式转出来.
- tubey: 版面垂直附有弹性的转出来.
- swirl: 旧版面360度旋转并淡出, 显示出新版面.
- charminUltra: 旧版面淡出并显示新版面.
- zoomyIn: 新版面由小放大走到前面, 旧版面放大由前面消失.
- zoomyOut: 新版面屏幕外面缩放出现, 旧版面缩小消失.
- oglApplicationSuspend: 像按"home" 按钮的效果.
*/
IOS4.0新方法:
方法: +(void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; //多一个动画结束后可以执行的操作.
//下边是嵌套使用,先变大再消失的动画效果.
[UIView animateWithDuration:1.25 animations:^{
CGAffineTransform newTransform = CGAffineTransformMakeScale(1.2, 1.2);
[firstImageView setTransform:newTransform];
[secondImageView setTransform:newTransform];}
completion:^(BOOL finished){
[UIView animateWithDuration:1.2 animations:^{
[firstImageView setAlpha:0];
[secondImageView setAlpha:0];} completion:^(BOOL finished){
[firstImageView removeFromSuperview];
[secondImageView removeFromSuperview]; }];
}];

浙公网安备 33010602011771号