How to present a View above everything in SwiftUI?

Hello,

I'm trying to present an app overlay (like an HUD) that should appear on top of everything (the app UI could be the root content view or a modal presented from the content view or a modal over a modal presented from the content view, etc.). If I use a ZStack for example, the issue is that the view is not visible if the ZStack is presenting a modal for example. In UIKit, I think we can use instantiate another UIWindow to show content above the top window of the app (what a native alert does if I'm not wrong).

What would be the equivalent in SwiftUI? How could I create this?

Thanks,

Axel

Hello @alpennec,

There might be a few ways to achieve the visual effect you're looking for.

Try using an .overlay or share your approach with ZStack below, provide a bit more details about your expected goal.

You also might want to get started with the Human Interface Guidelines and the iOS Pathway for beginner tutorials.

There's also great examples in our sample code Wishlist.

 Travis

How to present a View above everything in SwiftUI?
 
 
Q