with UIView.animate.

let iv = UIImageView()
iv.frame = .init(x: 0, y: 0, width: 100, height: 100)
 UIView.animate(withDuration: 0.4) {
     iv.frame = .init(x: 0, y: 0, width: 100, height: 0) // If set width or height to 0, image will disapper immediately.
     iv.frame = .init(x: 0, y: 0, width: 100, height: 1) // Unless need 1 point for animate.
 }