UIView动画

转载自 http://www.cnblogs.com/zhidao-chen/archive/2013/04/18/3028864.html

在frameworks中添加QuartzCore.framework 

在接口程序中加上头文件   #import <QuartzCore/QuartzCore.h> 
用 CATransition 

创建transition 
    CATransition *transition = [CATransition animation]; 
    transition.duration = 1.0f;         /* 间隔时间*/ 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; /* 动画的开始与结束的快慢*/ 
    transition.type = @"rippleEffect"; /* 各种动画效果*/ 
//@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip" 

    transition.subtype = kCATransitionFromRight;   /* 动画方向*/ 
    transition.delegate = self; 

    [navigationController.view.layer /* 在想添加CA动画的VIEW的层上添加此代码*/addAnimation:transition forKey:nil]; 
//另外加一句,transition在申请时用的是+方法,所以不需要自己进行release ,在层上添加后不要认为retainCount已经+1,就还要release 

//降效果作用到view的层上面 
//实际上CATransition类中还有一个属性是removedOnCompletion,是此动画执行完后会自动remove,默认值为true 

//降效果作用到view的层上面 
[self.view.layer addAnimation:transition forKey:@"animation"]; 

UIView Animation 
//开始一个动画块 
[UIView beginAnimations:@"animationID" context:nil]; 
//设置动画块中的动画持续时间(用秒) 
[UIView setAnimationDuration:0.5f]; 
//设置动画块中的动画属性变化的曲线 
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
//变化曲线还有 
(    UIViewAnimationCurveEaseInOut,         // slow at beginning and end 
    UIViewAnimationCurveEaseIn,            // slow at beginning 
    UIViewAnimationCurveEaseOut,           // slow at end 
    UIViewAnimationCurveLinear) 

//设置动画块中的动画效果是否自动重复播放。 
[UIView setAnimationRepeatAutoreverses:NO]; 

//设置动画在动画模块中的重复次数 
//setAnimationRepeatCount: 
//设置动画消息的代理。 
[UIView setAnimationDelegate:self]; 
[UIView 
//设置消息给动画代理当动画开始的时候 
setAnimationWillStartSelector:@selector(resizeAnimationWillStart:context:)]; 
[UIView 
//设置消息给动画代理当动画停止的时候 
setAnimationDidStopSelector:@selector(resizeAnimationDidStop:finished:context:)]; 


//将效果作用在指定的view 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; 

效 果还有 (UIViewAnimationTransitionFlipFromLeft,UIViewAnimationTransitionFlipFromRight,UIViewAnimationTransitionCurlUp,UIViewAnimationTransitionCurlDown) 

//显示在最前面 
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0]; 
//结束动画 
[UIView commitAnimations]; 

//

  用block写的

[UIViewanimateWithDuration:1.3animations:^{

            label.alpha = 0;

            

        }];

懒得打字 。资源来源:http://sdlqhjk.iteye.com/blog/1062072

原文地址:https://www.cnblogs.com/allanliu/p/4203321.html