override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// create new view
let newView = UIImageView(image: UIImage(named: "banner"))
newView.center = animationContainerView.center
// add the enw view via transition
UIView.transition(with: animationContainerView,
duration: 0.33,
options: [.curveEaseOut, .transitionFlipFromBottom],
animations: {
self.animationContainerView.addSubview(newView)
}, completion: nil)
create a new view named newView in viewDidAppear, ‘newView’ is a local variable, why ‘newView’ is global variable when removing ?
//remove the view via transition
UIView.transition(with: animationContainerView, duration: 0.33,
options: [.curveEaseOut, .transitionFlipFromBottom],
animations: {
self.newView.removeFromSuperview()
}, completion: nil)