UIImageView实现简单动画
2016-09-28 09:25
357 查看
关于ios动画,自己在以往的开发中用到的很少,这次遇到这么个需求:在一个操作完成前我需要加上动画效果,其实只是两张图片不断替换。图片当然用UIImageview加载。在请教别人之后,知道了uiimageview使用动画的方法,我又把它跟MBProgressHUD相结合使用,代码如下:
//添加开门动画
MBProgressHUD *
animationHud= [[MBProgressHUD
alloc]
initWithView:self.view];
[animationHud
setRemoveFromSuperViewOnHide:YES];
UIView *view =[[UIView
alloc]initWithFrame:CGRectMake(0,0,
57,
81)];
UIImageView *imageview=[[UIImageView
alloc]initWithImage:[UIImage
imageNamed:@"icon_open.png"]];
imageview.animationImages = [NSArray
arrayWithObjects: [UIImage
imageNamed:@"icon_open_noCharacter"],[UIImage
imageNamed:@"icon_close_noCharacter"],nil];
imageview.animationDuration =
0.5f;
imageview.animationRepeatCount =
0; //0代表无限大
imageview.userInteractionEnabled =
YES;
[imageview startAnimating];
imageview.frame=view.frame;
[view addSubview:imageview];
[animationHud
setCustomView:view];
[animationHud
setMode:MBProgressHUDModeCustomView];
[self.view
addSubview:animationHud];
[animationHud
show:YES];
//添加开门动画
MBProgressHUD *
animationHud= [[MBProgressHUD
alloc]
initWithView:self.view];
[animationHud
setRemoveFromSuperViewOnHide:YES];
UIView *view =[[UIView
alloc]initWithFrame:CGRectMake(0,0,
57,
81)];
UIImageView *imageview=[[UIImageView
alloc]initWithImage:[UIImage
imageNamed:@"icon_open.png"]];
imageview.animationImages = [NSArray
arrayWithObjects: [UIImage
imageNamed:@"icon_open_noCharacter"],[UIImage
imageNamed:@"icon_close_noCharacter"],nil];
imageview.animationDuration =
0.5f;
imageview.animationRepeatCount =
0; //0代表无限大
imageview.userInteractionEnabled =
YES;
[imageview startAnimating];
imageview.frame=view.frame;
[view addSubview:imageview];
[animationHud
setCustomView:view];
[animationHud
setMode:MBProgressHUDModeCustomView];
[self.view
addSubview:animationHud];
[animationHud
show:YES];
相关文章推荐
- 用UIImageView自带方法实现简单动画
- IOS中UIImageView方法实现简单动画
- Swift-UIImageView简单动画实现原理
- UIImageView动画 、自定义View 和手势的简单实用 Tom 猫 全部功能实现
- iOS UIImageview实现简单动画
- 利用UIImageView实现动画
- 【iOS开发-9】UIImage和UIImageView属性介绍,实现图片动画,实现开始/停止按钮效果
- iOS:CAKeyframeAnimation实现UIImageView精准时间的动画结束事件
- swift UIImageView简单动画
- 利用UIImageView实现动画
- iphone开发 UIImageView制作简单动画
- swift用animateWithDuration实现简单view切换动画
- iPhone开发教程之利用 UIImageView 实现全屏动画的代码例子
- Swift UIImageView简单动画
- 设置ViewPager的切换动画简单的实现
- 关于动画的切换可以用UIImageView中的属性来实现。
- UIImageView动画实现
- 实现UIImageView播放图片动画结束通知
- UIImageView 实现播放动画
- 利用 UIImageView 实现全屏动画的代码例子