12345678_0001
使用新的基于块的UIKit动画方法可以更加简单。假设以下代码位于视图控制器中,并且您要交叉溶解的UIImageView是可通过属性self.imageView寻址的self.view的子视图。然后,您需要做的就是:UIImage * toImage = [UIImage imageNamed:@"myname.png"];[UIView transitionWithView:self.imageView duration:5.0f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ self.imageView.image = toImage; } completion:nil];做完了并在Swift中进行操作,就像这样:let toImage = UIImage(named:"myname.png")UIView.transitionWithView(self.imageView, duration:5, options: UIViewAnimationOptions.TransitionCrossDissolve, animations: { self.imageView.image = toImage }, completion: nil)斯威夫特3.0 let toImage = UIImage(named:"myname.png") UIView.transition(with: self.imageView, duration: 0.3, options: .transitionCrossDissolve, animations: { self.imageView.image = toImage }, completion: nil)