I wouldn't normally recommend using imageNamed and relying on the in-built caching mechanisms. You'll find a lot of discussion on this if you search, but also it won't necessarily pre-render your images anyway.
I use the following code to pre-load and pre-render images so there is no delay when animating the first time through.
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 imageUIImage*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;
全站熱搜
留言列表