渐隐渐现效果代码
来源:互联网 发布:linux发送syslog 编辑:程序博客网 时间:2024/05/07 11:06
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
// only respond to mouse down events
UITouch *touch = [touches anyObject];
if ([touchphase] !=UITouchPhaseBegan)return;
isVisible = !isVisible;
// perform the fade out or fade in
CGContextRef context =UIGraphicsGetCurrentContext();
[UIView beginAnimations:nilcontext:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[[selfviewWithTag:IMAGE_VIEW_TAG]setAlpha:(float)isVisible];
[UIView commitAnimations];
}
转别人的
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];
}
- 渐隐渐现效果代码
- 渐隐渐现效果代码
- 推进视图渐隐渐现效果实现代码
- 代码实现Android中View的渐隐渐现效果
- iOS渐隐渐现效果跳转
- C#自我总结: 窗体渐隐渐现效果
- android图片渐隐渐现动画效果
- 开启动画效果——渐隐渐现效果
- 开启动画效果——渐隐渐现效果
- UGUI 实现界面 渐隐渐现 FadeIn/Out 效果
- JQuery渐隐渐现
- 渐隐渐现动画
- UGUI DOTween渐隐渐现
- banner渐隐渐现
- UGUI DOTween渐隐渐现
- UI移动和渐隐渐现
- 图片的渐隐渐现特效代码
- 解决IE下图片渐隐渐现效果,图片出现“坏点”的bug
- .NET程序国际化方法
- KS日记
- 程序的工作过程 eip寄存器
- NSDateFormatter NSDateComponents iphone 时间格式详解
- Javascript中的onmusewheel事件
- 渐隐渐现效果代码
- Android AlphaAnimation\TranslateAnimation 多组动画循环+单个动画结束后闪烁问题
- MB与MQ简介
- 实践中探索Android智能手机系统------ROM分区
- javascript 格式化和语法检查链接网站
- iOS-ssh无密码登入设置
- java学习
- nginx&&apache最简单的网站安全策略实现
- 人人客户端滑动效果的简单实现