Thursday, April 30, 2026
HomeiOS Developmentios - Displaying Overlay Aligning to the Backside

ios – Displaying Overlay Aligning to the Backside

[ad_1]

I need to lay a View over one other once I faucet a button. The next is my code.

import SwiftUI

struct SheetView: View {
    @State personal var showSheet: Bool = false
    var physique: some View {
        NavigationView {
            VStack {
                ZStack {
                    Rectangle()
                        .fill(Colour.orange)
                        .body(top: 32.0)
                    Button("Please choose a mailing deal with") {
                        showSheet.toggle()
                    }.foregroundColor(Colour.black)
                }
                Spacer()
            }
            .navigationBarTitleDisplayMode(.inline)
            .navigationViewStyle(StackNavigationViewStyle())
        }
        .overlay(popOver)
    }
    
    var popOver: some View {
        Group {
            if showSheet {
                ZStack {
                    Colour.black.opacity(0.4).ignoresSafeArea()
                    ZStack {
                        Rectangle()
                            .fill(Colour.white)
                            //.body(width: UIScreen.major.bounds.width, top: 400)
                            .body(maxWidth: .infinity, maxHeight: 320.0, alignment: .backside)
                            //.place(x: UIScreen.major.bounds.width / 2.0, y: 600)
                    }
                }.onTapGesture {
                    showSheet.toggle()
                }
            }
        }
    }
}

And it appears like the next image. I get just about what I want besides that the overlaid View will seem on the middle. How can I make it seem, aligning to the underside of the underside View? Thanks.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments