1

I'm presenting a mostly transparent ViewController over another one right now, but it disables interaction with the ViewController underneath. Here is the code I am using as of now:

topController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
bottomController.modalPresentationStyle = UIModalPresentationStyle.currentContext
bottomController.present(topController, animated: true, completion: nil)

How do I partially present the top controller over the bottom controller while still allowing the bottom controller to be interacted with?

bigreddawg
  • 723
  • 1
  • 5
  • 10

1 Answers1

0

If you want to interact with bottomController you should add UIViewController as ChildViewController:

bottomController.addChildViewController(topController)
bottomController.view.addSubview(topController.view)
//set here frame or constraints for topController.view

If you want to dismiss topController you should call:

topController.removeFromParentViewController()
topController.view.removeFromSuperview()

For animations you can use:

UIView.animate(withDuration duration: TimeInterval, animations: @escaping () -> Void)
Karol
  • 11
  • 2
  • I've just done this, but I don't know how to set the frame of the top ViewController so that it doesn't disable the top one. When I set the top controller's frame to a CGRect, it succeeds in changing the frame, but ends up disabling the top controller. – bigreddawg Aug 20 '18 at 04:56