iOS 使用图片数组实现动画

实现效果

2021-09-26 19.37.14.gif

实现代码

    self.imageView.animationDuration = 1;
    NSMutableArray *imageArray = [NSMutableArray array];
    for (int i = 0 ; i < 56; i ++) {
        NSString *imageName;
        if (i < 10) {
            imageName = [NSString stringWithFormat:@"18s_0000%d",I];
        } else {
            imageName = [NSString stringWithFormat:@"18s_000%d",I];
        }
        UIImage *image = getImageWithName(imageName);
        [imageArray addObject:image];
    }
    self.imageView.animationImages = imageArray;
    self.imageView.animationRepeatCount = 1;
    [self.imageView startAnimating];

你可能感兴趣的:(iOS 使用图片数组实现动画)