我有UIIamge
我在viewDidLoad
的{{1}}中以编程方式创建了DetailViewController
。我想在其当前图像与另一图像之间.transitionCrossDissolve
。我的问题是,一旦显示DetailViewCOntroller
,无论duration
如何,都会立即切换。我甚至都看不到第一张图片。我使用以下代码。
let rect = CGRect(x: 0, y: UIApplication.shared.statusBarFrame.height, width: view.frame.size.width, height: view.frame.size.height / 3.0)
let imageView = UIImageView(frame: rect)
imageView.image = #imageLiteral(resourceName: "head1")
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
view.addSubview(imageView)
UIView.transition(with: imageView,
duration: 16.0,
options: .transitionCrossDissolve,
animations: { imageView.image = #imageLiteral(resourceName: "head3") },
completion: nil)
答案 0 :(得分:1)
尝试在viewDidAppear
委托中启动动画。认为这就是问题。