/**
* 关于图片加载的两种方式:
*
* 1:APP启动就将图片全部读进内存,加载图片会很快,但是图片有多大会占用内存,应用所能占用的内存是有一定限制的
* 2:使用时,从磁盘读取图片文件,相对内存读取会稍稍慢一点,但没有什么大碍
*
* 两种使用环境:
* 1..频繁使用的小图片,用读进内存的方法。
* 2..不常用的大图片,用现读文件的方法
*
* 举例:一个Table,每个Cell都有一个下载按钮的图片,用读进内存的方法.
* 应用有几页引导页面(全屏大小),现读文件
*/
UIImage *secondImage = [UIImage imageNamed:@"1_1.png"];
UIImage *thirdImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1_2" ofType:@"png"]];
UIImageView *secondImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 360, 171)];
secondImageView.image = secondImage;
//1、根据读进来的图片的大小来确认image
UIImageView *thirdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 200, thirdImage.size.width, thirdImage.size.height)];
thirdImageView.image = thirdImage;
//2、UIImageView的动画
NSMutableArray *picArr = [NSMutableArray arrayWithCapacity:0];
for(int i =1;i<13;i++)
{//数组里存的是UIImage对象,不是图片名字符串
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"player%d.png",i]];
[picArr addObject:image];
}
//3..将多张图片开始播放
// 1、实例化一个UIImageView
// 2、把要动画的图片Image用数组赋值
// 3、动画持续时长,是一轮的时长
// 4、重复轮数 0表示无限次
// 5、准备完成后,开始轮播
UIImageView *animateImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 400, 60, 60)];
animateImage.animationImages = picArr;
animateImage.animationDuration = 0.5;
animateImage.animationRepeatCount = 0;
[self.view addSubview:animateImage];
[animateImage startAnimating];