I want to set the padding to -15 only when showBar
= false
. How do I add the condition for this inside padding parameters?
This is for macOS 10.15 app.
@State private var showBar = true
VStack {
WebView
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.edgesIgnoringSafeArea(.all)
.padding(.top, -15)
Use ternary operator right inside modifier, like
.frame(maxWidth: .infinity, maxHeight: .infinity)
.edgesIgnoringSafeArea(.all)
.padding(.top, showBar ? 0 : -15) // << here !!