我现在在另一个上方展示一个几乎透明的ViewController,但是它禁用了与下面的ViewController的交互。这是到目前为止我正在使用的代码:
topController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
bottomController.modalPresentationStyle = UIModalPresentationStyle.currentContext
bottomController.present(topController, animated: true, completion: nil)
如何在顶部控制器上方部分显示顶部控制器,同时又允许底部控制器与之交互?
答案 0 :(得分:0)
如果您想与bottomController
进行交互,则应将UIViewController
添加为ChildViewController:
bottomController.addChildViewController(topController)
bottomController.view.addSubview(topController.view)
//set here frame or constraints for topController.view
如果您要撤消topController
,请致电:
topController.removeFromParentViewController()
topController.view.removeFromSuperview()
对于动画,您可以使用:
UIView.animate(withDuration duration: TimeInterval, animations: @escaping () -> Void)