animatedImageNamed :duration:
Creates and returns an animated image.
+ (UIImage *)animatedImageNamed:(NSString *)name duration:(NSTimeInterval)duration
Parameters
- name
- The full or partial path to the file (sans suffix).
- duration
- The duration of the animation.
Return Value of [UIImage animatedImageNamed]
A new image object.
Discussion of [UIImage animatedImageNamed]
This method loads a series of files by appending a series of numbers to the base file name provided in the name parameter. For example, if the name parameter had ‘image’ as its contents, this method would attempt to load images from files with the names ‘image0’, ‘image1’ and so on all the way up to ‘image1024’. All images included in the animated image should share the same size and scale.
Example of [UIImage animatedImageNamed]
Having images of
refresh-0.png, refresh-1.png, refresh-2.png, refresh-3.png, refresh-4.png
UIImage *image = [UIImage animatedImageNamed:@"refresh-" duration:1.f];
self.button = [[UIBarButtonItem alloc] initWithImage:image
style:UIBarButtonItemStyleBordered
target:self
action:@selector(doSomething:)];