iPhone开发--渐隐渐显动画效果

1、最简单,最实用,最常用的[移动动画]

//移动一个view

---------------------------------------------------------------------------------------------------------------------------------

+(void)MoveView:(UIView *)view To:(CGRect)frame During:(float)time{

// 动画开始

[UIView beginAnimations:nil context:nil];

// 动画时间曲线 EaseInOut效果

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

// 动画时间

[UIView setAnimationDuration:time];

view.frame = frame;

// 动画结束(或者用提交也不错)

[UIView commitAnimations];

}

---------------------------------------------------------------------------------------------------------------------------------

适用范围:

常常出现在ipad项目中,当用户点击一个图片,或者一条资讯,你将弹出一个详细页面[detailview],将起始frame初始化为 cgrectmake(self.view.frame.size.width/2,self.view.size.height/2, 0, 0),结束位置[frame] ,常用的动画间隔时间0.4f-0.6f。

[AnimtionTool MoveView:detailview To:frame During:0.5f];

效果,页面中间将从小到大显示一个view[detailview]


2、渐渐显示一个view,需要在调用此方法的类中重写此方法

---------------------------------------------------------------------------------------------------------------------------------

/*

- (void)onAnimationComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

      if ([animationID isEqualToString: SHOW_VIEW]) {

         //do something

      }  else if ([animationID isEqualToString:HIDDEN_VIEW]) {

         //do something

      }

}

*/

+(void)ShowView:(UIView *)view To:(CGRect)frame During:(float)time delegate:(id)delegate;{

[UIView beginAnimations:SHOW_VIEW context:nil];

[UIView setAnimationDuration:time];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

if(delegate !=nil &&[delegate respondsToSelector:@selector(onAnimationComplete:finished:context:)]){

[UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];

[UIView setAnimationDelegate:delegate];

}

view.hidden = NO;

view.layer.opacity = 1.0;

view.frame = frame;

[UIView commitAnimations];

}

---------------------------------------------------------------------------------------------------------------------------------

3、渐渐隐藏一个view

---------------------------------------------------------------------------------------------------------------------------------

+(void)HiddenView:(UIView *)view To:(CGRect)frame During:(float)time delegate:(id)delegate{

[UIView beginAnimations:HIDDEN_VIEW context:nil];

[UIView setAnimationDuration:time];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

if(delegate !=nil &&[delegate respondsToSelector:@selector(onAnimationComplete:finished:context:)]){

[UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];

[UIView setAnimationDelegate:delegate];

}

view.frame = frame;

view.layer.opacity = 0.0;

[UIView commitAnimations];

}

---------------------------------------------------------------------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值