I would like to be able to add a modal view in front of my table view, that is displayed relative to the view rather than relative to the table view (as shown in the photos)1. Also how do I prevent the user interacting with the table behind. I have included the code used to animate my view in also. Thanks in advance!
func newPersonAnimateIn() {
self.overlayView.transform = CGAffineTransform.identity
self.view.addSubview(overlayView)
overlayView.center = self.view.center
overlayView.transform = CGAffineTransform.init(scaleX: 1.3, y: 1.3)
overlayView.alpha = 0
UIView.animate(withDuration: 0.4) {
//self.visualEffectView.effect = self.effectHolder
self.overlayView.alpha = 1
self.overlayView.transform = CGAffineTransform.identity
}
personName.becomeFirstResponder()
}
func newPersonAnimateOut() {
self.view.endEditing(true)
UIView.animate(withDuration: 0.3, animations: {
self.overlayView.alpha = 0
self.overlayView.transform = CGAffineTransform.identity
}){(success:Bool) in
self.overlayView.removeFromSuperview()
}
personName.text = ""
}
@IBAction func addPerson(_ sender: UIBarButtonItem) {
newPersonAnimateIn()
}
@IBAction func continueButton(_ sender: Any) {
newPersonAnimateOut()
}
Maybe this would be enough:
or create another view under your modal view that covers full screen and set isUserInteractionEnabled = false