最初のアニメーションでの遅延を回避するのに非常に役立つこのコードを見つけました:
NSMutableArray *menuanimationImages = [[NSMutableArray alloc] init];
for (int aniCount = 1; aniCount < 21; aniCount++) {
NSString *fileLocation = [[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @"bg%i", aniCount + 1] ofType: @"png"];
// here is the code to pre-render the image
UIImage *frameImage = [UIImage imageWithContentsOfFile: fileLocation];
UIGraphicsBeginImageContext(frameImage.size);
CGRect rect = CGRectMake(0, 0, frameImage.size.width, frameImage.size.height);
[frameImage drawInRect:rect];
UIImage *renderedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[menuanimationImages addObject:renderedImage];
}
settingsBackground.animationImages = menuanimationImages;
しかし、私は時々同じ画像を使用したい - 配列の上のコード内に手動で入力できますか
testArray = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"test_001.png"],
[UIImage imageNamed:@"test_002.png"],
[UIImage imageNamed:@"test_001.png"],
nil];
アイデアをありがとう!