[iOS]UIImageView动画相关
2014-02-23 12:51
309 查看
[iOS]UIImageView动画相关
用UIImageView自带方法实现简单动画
Demo:http://download.csdn.net/detail/u012881779/9734998
#import "FirstViewController.h"
@interface FirstViewController ()
@property (strong, nonatomic) UIImageView *loadingImageView;
@end
@implementation FirstViewController
@synthesize loadingImageView = _loadingImageView;
- (void)viewDidLoad {
[super viewDidLoad];
// 加载本地动画
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:
[UIImage imageNamed:@"loading_image0.png"],
[UIImage imageNamed:@"loading_image1.png"],
[UIImage imageNamed:@"loading_image2.png"],
[UIImage imageNamed:@"loading_image3.png"],
[UIImage imageNamed:@"loading_image4.png"],
[UIImage imageNamed:@"loading_image5.png"],
[UIImage imageNamed:@"loading_image6.png"],
[UIImage imageNamed:@"loading_image7.png"],
nil];
_loadingImageView = [[UIImageView alloc] init];
_loadingImageView.animationImages = array;
// 用于图像的一个循环, 默认为 图像数量*1/30秒(即30fps-每秒传输帧数)
_loadingImageView.animationDuration = 1;
_loadingImageView.hidden = YES;
[_loadingImageView setFrame:CGRectMake(10, 74, 34, 34)];
[self.view addSubview:_loadingImageView];
}
// 开始加载动画
- (void)startLoadingAnimation {
if (_loadingImageView != nil) {
_loadingImageView.hidden = NO;
[_loadingImageView startAnimating];
}
}
// 停止加载动画
- (void)stopLoadingAnimation {
if (_loadingImageView != nil) {
_loadingImageView.hidden = YES;
[_loadingImageView stopAnimating];
}
}
- (IBAction)animationAction:(id)sender {
UIButton *tempBut = (UIButton *)sender;
if(tempBut.tag == 200){
// 开始动画
[self startLoadingAnimation];
}else if (tempBut.tag == 201){
// 停止动画
[self stopLoadingAnimation];
}
}
@end
示意图:
用UIImageView自带方法实现简单动画
Demo:http://download.csdn.net/detail/u012881779/9734998
#import "FirstViewController.h"
@interface FirstViewController ()
@property (strong, nonatomic) UIImageView *loadingImageView;
@end
@implementation FirstViewController
@synthesize loadingImageView = _loadingImageView;
- (void)viewDidLoad {
[super viewDidLoad];
// 加载本地动画
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:
[UIImage imageNamed:@"loading_image0.png"],
[UIImage imageNamed:@"loading_image1.png"],
[UIImage imageNamed:@"loading_image2.png"],
[UIImage imageNamed:@"loading_image3.png"],
[UIImage imageNamed:@"loading_image4.png"],
[UIImage imageNamed:@"loading_image5.png"],
[UIImage imageNamed:@"loading_image6.png"],
[UIImage imageNamed:@"loading_image7.png"],
nil];
_loadingImageView = [[UIImageView alloc] init];
_loadingImageView.animationImages = array;
// 用于图像的一个循环, 默认为 图像数量*1/30秒(即30fps-每秒传输帧数)
_loadingImageView.animationDuration = 1;
_loadingImageView.hidden = YES;
[_loadingImageView setFrame:CGRectMake(10, 74, 34, 34)];
[self.view addSubview:_loadingImageView];
}
// 开始加载动画
- (void)startLoadingAnimation {
if (_loadingImageView != nil) {
_loadingImageView.hidden = NO;
[_loadingImageView startAnimating];
}
}
// 停止加载动画
- (void)stopLoadingAnimation {
if (_loadingImageView != nil) {
_loadingImageView.hidden = YES;
[_loadingImageView stopAnimating];
}
}
- (IBAction)animationAction:(id)sender {
UIButton *tempBut = (UIButton *)sender;
if(tempBut.tag == 200){
// 开始动画
[self startLoadingAnimation];
}else if (tempBut.tag == 201){
// 停止动画
[self stopLoadingAnimation];
}
}
@end
示意图:
相关文章推荐
- IOS1.7-UIImageView的帧动画相关属性和方法 (示例汤姆猫)
- iOS - UIImageView 动画
- IOS开发-UI学习-使用UIImageView控件制作动画
- iOS --- 使用UIImageView来实现倒计时动画
- [IOS]UIImageView动画
- IOS使用UIImageView显示gif动画的例子
- IOS开发-给UIImageView赋无限循环动画
- IOS中UIImageView方法实现简单动画
- iOS UIImageView Gif 动画
- IOS 利用UIImageView实现加载动画
- iOS开发之UIImageView的图片变化动画
- iOS控件——UIView与UIImageView播放动画的实现方法
- ios UIimageView 手势移动动画效果
- ios动画:获取处于动画中的UIView,UIImageView的坐标
- IOS UI学习教程之使用UIImageView控件制作动画
- 【iOS开发】关于显示一连串图片组成动画效果UIImageView的使用
- iOS基础控件-UIImageView,图片视图,配合点击手势,点击一个图片,开始动画
- iOS:UIimageView切换图片渐入渐出的动画
- iOS UIImageview实现简单动画
- 【iOS开发-9】UIImage和UIImageView属性介绍,实现图片动画,实现开始/停止按钮效果