UIImage 应用实例制作

下文将主要讲述利用UIImage对象制作一个动画
如下代码所示:

 
    //生成UIImageView对象
    UIImageView *UIImageViewTmp = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0,
                                                                               self.view.frame.size.width,
                                                                               self.view.frame.size.height)];
    //设置默认颜色
    [UIImageViewTmp setBackgroundColor:[UIColor blueColor]];
    
    
    
    //生成六个UIImage对象
     UIImage *UIImageTmp1 = [UIImage imageNamed:@"1.jpg"];
    UIImage *UIImageTmp2 = [UIImage imageNamed:@"2.jpg"];
    UIImage *UIImageTmp3 = [UIImage imageNamed:@"3.jpg"];
    UIImage *UIImageTmp4 = [UIImage imageNamed:@"4.jpg"];
    UIImage *UIImageTmp5 = [UIImage imageNamed:@"5.jpg"];
    UIImage *UIImageTmp6 = [UIImage imageNamed:@"6.jpg"];
    
    //将UIImage对象生成一个数组
    NSArray *UIImageArr = @[UIImageTmp1,UIImageTmp2,UIImageTmp3,UIImageTmp4,UIImageTmp5,UIImageTmp6];
    
    
    UIImageViewTmp.animationImages = UIImageArr; //设置图片播放所涉及的图像数组
    UIImageViewTmp.animationDuration = 3; //所有图片播放完毕总秒数
    UIImageViewTmp.animationRepeatCount = 0; //设置重复次数 0代表重复无限次数
    
    [UIImageViewTmp startAnimating];  //开始播放动画
    
    [self.view addSubview:UIImageViewTmp];
    UIImageViewTmp = nil;
    

相关阅读:
UIImage对象创建(二)
UIImage对象简介(一)