I want to click a button and then present a new view like present modally
in UIKit
I have already seen "How to present a new view using sheets", but I don't want to attach it to the main view as a modal sheet.
And I don't want to use NavigationLink
, because I don't want a new view and old view have a navigation relationship.
Thanks for your help...
Disclaimer: Below is not really like a "native modal", neither behave nor look&feel, but if anyone would need a custom transition of one view over other, making active only top one, the following approach might be helpful.
So, if you expect something like the following
Here is a simple code for demo the approach (of corse animation & transition parameters can be changed by wish)
Here is a simple one way - forward views. It's very straight forward.
To show a modal (iOS 13 style)
You just need a simple
sheet
with the ability to dismiss itself:And present it like:
Note that I passed the
presentingModal
to the modal so you can dismiss it from the modal itself, but you can get rid of it.To make it REALLY present
fullscreen
(Not just visually)You need to access to the
ViewController
. So you need some helper containers and environment stuff:Then you should use implement this extension:
Finally
you can make it
fullscreen
like: