I'm trying to create a simple page that has an option to select from a few different options, and then a text field and button that show up after an option has been selected. The logic works great, but unfortunately there's a great deal of white space between the Form object and the rest of the UI elements - is there a way to change this?
Here is the code:
VStack {
Text("What would you like help with?")
.font(.largeTitle)
.fontWeight(.bold)
.multilineTextAlignment(.center)
Form {
Picker("Color", selection: $selectedIndex) {
ForEach(0 ..< arrayOfNames.count) {
Text(self.arrayOfNames[$0])
}
}
}
TextField("Enter your question", text: $question)
.opacity(selectedIndex > 0 ? 1 : 0)
.textFieldStyle(RoundedBorderTextFieldStyle())
Button(action: {}) {
Text("Ask")
}.opacity(selectedIndex > 0 ? 1 : 0)
And here is an image which shows the problem: