iPhone开发--渐隐渐显动画效果
来源:互联网 发布:网络促销活动目标 编辑:程序博客网 时间:2024/05/21 11:24
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];
//移动一个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];
}
---------------------------------------------------------------------------------------------------------------------------------
转自:http://blog.csdn.net/andypan1314/article/details/6433358
- iPhone开发--渐隐渐显动画效果
- iPhone开发--渐隐渐显动画效果
- iPhone开发--渐隐渐显动画效果
- 鼠标触发图片渐隐渐显效果HTC
- 使用CanvasGroup实现渐隐渐显效果
- 如何实现先渐显再渐隐的动画?
- js实现图片渐隐渐显的切换效果
- 添加Tabbae渐隐动画效果
- 图片循环渐显渐隐
- Unity3d UI渐隐渐显
- 简单的带动画渐隐效果
- android图片渐隐渐现动画效果
- C#中窗体渐显渐隐
- jQuery实现带缩略图的渐显渐隐图片幻灯切换效果
- 用TransitionDrawable实现ImageView渐隐渐显过渡效果,并解决OutOfMemory问题
- iphone开发中的各种动画效果
- iphone开发中的各种动画效果
- iphone开发中的各种动画效果
- 创建数据链database link and drop (简单实例)
- SQL点滴27—性能分析之执行计划
- Linux文件系统
- 经典人生感悟
- Mozilla项目Boot to Gecko
- iPhone开发--渐隐渐显动画效果
- Linux下截图工具
- C# 使用位运算来实现权限管理
- <备忘>关于结构体
- Linux下的svn常用命令
- FCKeditor 详细配置
- SQL点滴26—常见T-SQL面试解析
- js history.go 使用浏览器缓存
- C++遍历文件夹