Шаг: 1 - В раскадровке создайте новый VC, создайте новый UIView внутри VC.назовите его (ViewPopupUI), а затем объявите необходимые поля и свойства внутри ViewPopupUI.
Шаг: 2 - Внутри VC
@IBOutlet private weak var viewPopupUI:UIView!
@IBOutlet var btnClose: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
self.showViewWithAnimation()
}
@IBAction func btnCloseAction(_ sender: Any) {
self.hideViewWithAnimation()
}
//MARK: - Animation Method
private func showViewWithAnimation() {
self.view.alpha = 0
self.viewPopupUI.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
UIView.animate(withDuration: 0.3) {
self.viewPopupUI.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
self.view.alpha = 1
}
}
private func hideViewWithAnimation() {
UIView.animate(withDuration: 0.3, animations: {
self.viewPopupUI.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
self.view.alpha = 0
}, completion: {
(value: Bool) in
self.removeFromParent()
self.view.removeFromSuperview()
})
}
Всплывающее окно вызова
let popupVC = storyboard?.instantiateViewController(withIdentifier: "SchoolEventGoingPopup_VC") as! SchoolEventGoingPopup_VC
popupVC.strId = self.dictEventDetails?.object(forKey: "id") as? Int
view.addSubview(popupVC.view)
addChildViewController(popupVC)