1

I have built two separate UIViewControllers: MainVC and 2ndVC. Now I am trying to connect them and achieve the effect presented on the image below: enter image description here When loaded, 2ndVC should be visible partially on top of MainVC (let's say 1/4 of the screen). On swipe up 2ndVC should cover whole screen and on swipe down it should go back to starting point. I have some buttons on MainVC which I would like to stay active when 2ndVC does not cover whole screen.

2ndVC's height will change dynamically dependently on data. It has scrollview inside which should be active only when it covers whole screen.

What is the best way to do that? Should 2ndVC be embedded in container view as a child view controller? Should I somehow animate constraints of 2ndVC programmatically on swipe?

Bastek
  • 899
  • 1
  • 12
  • 27
  • 1
    Why you don't want use `UIView` instead second `UIViewController`? – Artem Novichkov Nov 30 '16 at 14:29
  • @ArtemNovichkov Because of its quite complex structure I built it as a UIViewController. After your comment I assume this way it will be much more complicated? – Bastek Nov 30 '16 at 14:35
  • Maybe. You can just create subclass of `UIView` and implement all needed logic inside it. – Artem Novichkov Nov 30 '16 at 14:37
  • @bastek I have a problem where in my similar setup, I can't get 2nd VC to animate in/out. It just jumps in/out. Did you manage to get the animation working, and if so, can you show some code? Thanks! – xaphod Apr 06 '17 at 23:39

1 Answers1

0

Probably a Container View Controller is what you are looking for:

https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html

Odrakir
  • 4,254
  • 1
  • 20
  • 52