Objective-c & large animated images

2020-02-16 02:04发布

问题:

So far I am using UIImageView with array of UIImages that are displaying one after another.

Same linke in this example:

NSArray *myImages = [NSArray arrayWithObjects:
                     [UIImage imageNamed:@"instruction_1"],
                     [UIImage imageNamed:@"instruction_2"],
                     [UIImage imageNamed:@"instruction_3"],
                     [UIImage imageNamed:@"instruction_2"],
                     [UIImage imageNamed:@"instruction_1"]
                     ,nil];

UIImageView *butta = [[UIImageView alloc] initWithFrame:frame];
butta.animationImages = myImages;
butta.animationDuration = 1;
butta.animationRepeatCount = 0;
butta.alpha = 0;
[butta startAnimating];

But the problem is that this solution works until images are small ... but in my case, most of them are same as device max resolution (over 2000 width and 1500 height for landscape retina ipad) ... and it has alpha channel (.png) ... that cause poor performance, especially over slower devices (even on iPad 3) ...

Do You know any good alternative? I tried .svg graphics, but it was even worst.

How can I optimize it?

Thanks in advance for any help, Regards David

回答1:

I've used AVAnimator before with great success. I had a similar issue in which I had to make very large images into a movie. There's a bit of a learning curve with it, but I believe he has numerous examples, which I just adapted to my use.