如何更改此代码以使动画如下所示: image1 --> image2 ---> image3 --->image4 --->image 5 .. 然后返回到 image1 等等...
编码:
UIImage *image1 = [UIImage imageNamed:@"1.jpg"];
UIImage *image2 = [UIImage imageNamed:@"2.jpg"];
UIImage *image3 = [UIImage imageNamed:@"3.jpg"];
UIImage *image4 = [UIImage imageNamed:@"4.jpg"];
UIImage *image5 = [UIImage imageNamed:@"5.jpg"];
NSArray *imageArray = [NSArray arrayWithObjects:image1.CGImage, image2.CGImage, image3.CGImage, nil];
//self.introImages.image = image1;
[self.view addSubview:self.introImages];
CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:@"contents"];
crossFade.autoreverses = YES;
crossFade.repeatCount = HUGE_VALF;
crossFade.duration = 1.0;
//self.introImages.layer.contents = image2.CGImage;
crossFade.fromValue = (id)image1.CGImage;
crossFade.toValue = (id)image5.CGImage;
[self.introImages.layer addAnimation:crossFade forKey:@"animateContents"];