Andrew
Andrew

Reputation: 2157

How to fix padding in ZStack

I have ZStack with two views one of which can be shown due to the condition:

ZStack{
            VStack{
                ...
            }.padding(.all,17)
            
            if handler.bottomVisible {
                BottomSheetView(handler: handler, player: true)
            }
        }

but when I uncomment these lines:

if handler.bottomVisible {
    BottomSheetView(handler: handler, player: true)
}

my .padding(.all,17) for VStack becomes damaged. Without this view, everything looks ok, but after adding the second child view for ZStack UI doesn't see paddings for VStack. Maybe I did smth wrong?

Example without bottom sheet:

enter image description here

and with the activated condition:

enter image description here

Upvotes: 0

Views: 4904

Answers (1)

Apix_D
Apix_D

Reputation: 1101

Well hard to answer your question because there is not so much code but you can try...

VStack(alignment: .leading) {

....
} .padding()

or you add the padding (.all, 17) information to all your textfields like

VStack{
    Text("Hello Stackoverflow")
    .padding(.all,17)
}

Upvotes: 1

Related Questions