Rendering a background image matching window frame, and under navigationTitle, in visionOS

43 views Asked by At

I managed to render a full width / height background with a modifier that looks like this.-

.background {
    AsyncImage(
        url: url,
        transaction: Transaction(animation: .easeIn)
    ) { phase in
        if let image = phase.image {
            image
            .resizable()
            .scaledToFill()
        } else if phase.error != nil  {
            EmptyView()
        } else {
            ProgressView()
        }
    }
    .containerRelativeFrame([.horizontal, .vertical])
}

But it still gets clipped by the navigation title bar. I'm aware I could just hide the full navigationBar with .navigationBarHidden(true) and then render the title and back button myself but, is it possible to keep the native navigationBar and render my background behind it?

1

There are 1 answers

0
ssantos On

Finally .ignoresSafeArea() modifier did the trick.