Reputation: 111
I want to create 20 different animation on the screen (the appearance and disappearance of image) with different times of the repetition these animation.
My code for one image
[UIView animateWithDuration:3.0f delay:0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations:^{
_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(148, 0, 17, 18)];
_imageVIew.image = [UIImage imageNamed:@"image.png»];
[self.view addSubview: _imageView];
[_star setAlpha:0];
[_star setAlpha:1];
} completion:nil];
If I use this code the devices heats up. How to reduce the load on the device?
Upvotes: 1
Views: 69
Reputation: 1365
Example you want to create a animation with these images
- (void)viewDidLoad
{
[super viewDidLoad];
// Load images
NSArray *imageNames = @[@"win_1.png", @"win_2.png", @"win_3.png", @"win_4.png",
@"win_5.png", @"win_6.png", @"win_7.png", @"win_8.png",
@"win_9.png", @"win_10.png", @"win_11.png", @"win_12.png",
@"win_13.png", @"win_14.png", @"win_15.png", @"win_16.png"];
NSMutableArray *images = [[NSMutableArray alloc] init];
for (int i = 0; i < imageNames.count; i++) {
[images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
}
// Normal Animation
UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 95, 86, 193)];
animationImageView.animationImages = images;
animationImageView.animationDuration = 0.5;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];
}
You can see more here http://www.appcoda.com/ios-programming-animation-uiimageview/
Upvotes: 1