I have two UIViewControllers
and I would like to .present
the gray UIView
like you would usually present a ViewController
(appearing bottom up and user can slide down to dismiss).
Screenshots for a better understanding:
The bottomBar is a ContainerView
and should not change by switching between the VC's, only the gray UIView
which you can see in the 2nd picture.
I know I could just .present
ViewControllerB
without an animation and then just let the UIView
appear from out of the screen. But if I do it like this the user is not able to drag down the UIView
to dismiss
it.
This is how I present ViewControllerB
("wishlistViewController) at the moment.
let wishlistViewController = self.storyboard?.instantiateViewController(withIdentifier: "WishlistVC") as! WishlistViewController
wishlistViewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.navigationController?.present(wishlistViewController, animated: false)
}
Main Problem is that my UIView
is not fullscreen. Otherwise I could just .present
ViewControllerB
. However, with my design the background image would be animated by .presenting
or .dismissing
as well and I do not want that.
There is probably a very easy solution for this but I couldn't find on presenting ONLY a UIView
.
Grateful for any tips :)
Well, there are two answers I can think of:
1) If you want, you could just animate it in from the bottom using UIView.animate() on a y-position constraint it has, or on its layer's y-position attribute. You could then attach a UISwipeGestureRecognizer to it so that if you swipe down on it, it will animate back down.
2) Make your views that you'd like to present viewControllers and have them be presented with a custom modal animation. This sounds like more work than you wanna do though. Here's a cool tutorial on youtube that walks you through how to create a custom animation transition between 2 view controllers: https://www.youtube.com/watch?v=B9sH_VxPPo4
However, as far as I know, those .dismiss and .present methods are only meant for view controllers. Hopefully one of the two options I gave were helpful!