Check if this one works for you. I have bound the showing and hiding of popup to buttons but you can bind them to anything.

For this to work
- Drag and drop a uiview(your popup) into dock of view controller (see picture)

- Make outlet of your uiview(popup) in your view controller. I am calling it popupView
For showing popup with Animation use the code
@IBAction func btnShowPopupTapped(_ sender: UIButton) {
popupView.center = view.center
popupView.alpha = 1
popupView.transform = CGAffineTransform(scaleX: 0.8, y: 1.2)
self.view.addSubview(popupView)
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
//use if you want to darken the background
//self.viewDim.alpha = 0.8
//go back to original form
self.popupView.transform = .identity
})
}
And for hiding the popup
@IBAction func btnHideMeTapped(_ sender: Any) {
UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
//use if you wish to darken the background
//self.viewDim.alpha = 0
self.popupView.transform = CGAffineTransform(scaleX: 0.2, y: 0.2)
}) { (success) in
self.popupView.removeFromSuperview()
}
}
Note: If you want to darken the background as in gif.
- Drag and drop a uiview into your view heirarchy (view dim). see the pic

- pin to 0, 0 , 0 ,0 to the main view
- set its background color to black
- set is alpha to 0
- uncomment the line (self.viewDim.alpha = 0.8) in "btnShowPopupTapped" Action
- uncomment the line (self.viewDim.alpha = 0) in "btnHideMeTapped" Action
Let me know if this helps.