用UIimageView动态显示图片

    NSMutableArray *temparr = [NSMutableArray array];
    
    for (int i = 0; i < 7; i++)
    {
        UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%d.tiff",i]];
                    
        [temparr addObject:img];
    }
    
    self.imv  = [[[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]autorelease];
    
    self.imv.backgroundColor = [UIColor greenColor];
    
    [self addSubview:self.imv];
    
    self.imv.animationImages = temparr;
    //持续时间
    self.imv.animationDuration = 1;
    //循环次数,0为无限循环
    self.imv.animationRepeatCount = 0;
    //开始动画
    [self.imv startAnimating];


你可能感兴趣的:(用UIimageView动态显示图片)