0

enter image description here

I have to design a situation like above, consider: 1 - The blue viewController is the parent viewController 2 - The green is a modally presented viewController that updates it's size whenever the user clicks on button A, it moves a little up revealing Button B (middle screen), and when the user clicks on button B, it moves further up, revealing button C (last screen)

What have I tried so far? I went through the possibilities of implementing this and the best way I thought of (found here) is to use a custom subclass of UIPresentationController, using which I am able to present the green viewController as in the first screen. Now I am stuck at moving the green viewController up when button A is clicked, and move it up again when button B is clicked with sliding animation.

Any help is greatly appreciated.

Tejas K
  • 682
  • 11
  • 28
  • A few questions. (1) Is the blue view doing anything while you are presenting the green view? I' talking about needing the user to tap something and having your app react to it while presenting the green view. (2) How much of this is in a Storyboard? I could show you pure code that will (a) slide out/up the green view, (b) slide it out even further upon a button click, and (c) use `UIView.animate` for the slide effect. But it doesn't *present* a VC (it doesn't even *have* to use a second VC) but instead slides a view. –  Sep 17 '20 at 19:27
  • @dfd 1 - No, the blue view will be dimmed. 2- Almost everything is in storyboard, except presenting the green view and minor configurations. I would definately like to check out your code version of the solution. Thanks in advance. – Tejas K Sep 17 '20 at 20:05

1 Answers1

0

Here's what I did when I had a similar project recently:

  1. In view controller 2: Give it a clear background, and a green colored view anchored to the bottom so that it looks like your first image
  2. When you transition to that second view controller, make sure you present it modally with the option .overCurrentContext. That will give it the animation of sliding up over the blue view controller
  3. When you created that green view and constrained it in the storyboard, you would have either given it a top anchor or a height anchor. Either will work. Drag an outlet from that constraint so that you can access it through the code
  4. When the user presses a button, simply access that constraint and change its constant.
Dharman
  • 30,962
  • 25
  • 85
  • 135
CoolPineapple
  • 275
  • 1
  • 3
  • 11