-(IBAction)switchImg:(id)sender {}
现在填充其实现来完成UIImageView改变image时加入1秒的淡入淡出
方法1. 使用CATransition
CATransition *transition = [CATransition animation];
transition.type = kCATransitionFade;
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.imageView.layer addAnimation:transition forKey:nil];
UIImage *currentImage = self.imageView.image;
NSUInteger index = [self.imgs indexOfObject:currentImage];
index = (index +1) % [self.imgs count];
self.imageView.image = self.imgs[index];
方法2. 使用UIView类方法transitionWithView
UIImage *currentImage = self.imageView.image;
NSUInteger index = [self.imgs indexOfObject:currentImage];index = (index + 1) % [self.imgs count];
[UIView transitionWithView:self.imageView duration:1 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
self.imageView.image = self.imgs[index];
} completion:nil];