首页 > 代码库 > 利用图片序列创建动态图片效果

利用图片序列创建动态图片效果

代码:

- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.            //显示图片的UIImageView    UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];    imageview.backgroundColor=[UIColor redColor];    [self.view addSubview:imageview];        //动画的实现    NSMutableArray * images = [NSMutableArray arrayWithCapacity:6];    for (int i = 1; i <= 6; i++)    {        NSString * imageName = [NSString stringWithFormat:@"%d.jpg",i];        UIImage * image = [UIImage imageNamed:imageName];                [images addObject:image];    }    imageview.animationImages = images;    imageview.animationDuration = 0.3;    [imageview startAnimating];}

 

利用图片序列创建动态图片效果