Fading slide show in the image. xcode 4.2

I'm trying to make a slide show in an image view that also uses fade effects.

so far it has done:

- (void)viewDidLoad { [super viewDidLoad]; animationView = [[UIImageView alloc] initWithFrame:self.view.frame]; animationView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"photo1.jpg"], [UIImage imageNamed:@"photo2.jpg"], [UIImage imageNamed:@"photo3.jpg"], nil]; animationView.animationDuration = 5; animationView.animationRepeatCount = 0; [animationView startAnimating]; [self.view addSubview:animationView]; } 

the images appear one after another, with a delay of 5 seconds, what do I want now to make them disappear and disappear every time the image appears, any suggestions on this?

Thank you in advance for your help.

+4
source share
1 answer

I tried to do something like this. I set up a timer, which was called a UIView transitionWithView on a UIImageView , which was increasing in the array of my slide show photos.

 - (void)viewDidLoad{ [super viewDidLoad]; self.welcomePhotos = [NSArray arrayWithObjects:@"welcome_1.png",@"welcome_2.png", @"welcome_3.png", nil]; self.imageView1.image = [UIImage imageNamed:[self.welcomePhotos objectAtIndex:0]]; [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(transitionPhotos) userInfo:nil repeats:YES]; } -(void)transitionPhotos{ if (photoCount < [self.welcomePhotos count] - 1){ photoCount ++; }else{ photoCount = 0; } [UIView transitionWithView:self.imageView1 duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ self.imageView1.image = [UIImage imageNamed:[self.welcomePhotos objectAtIndex:photoCount]]; } completion:NULL]; } 
+6
source

Source: https://habr.com/ru/post/1401504/


All Articles