(Swift 5, SwiftUI) If I have the following code for a VStack:
struct ContentView: View {
var body: some View {
ScrollView {
VStack(alignment: .leading) {
//Inside of VStack
}.padding()
.padding(.bottom, keyboard.currentHeight)
.edgesIgnoringSafeArea(.bottom)
.animation(.easeOut(duration: 0.16))
}
}
}
How can I dynamically add Text()s to the VStack through a function and update the ScrollView height accordingly?
The function (is called by a button press):
func add() -> Void {
//Adds a Text() element to the VStack. The content of the Text() is received from an API
//call, so it can't be hardcoded.
}
I'm looking for a simple way to add Text() elements to my VStack. I've extensively searched for the problem on Google but found nothing similar to this trivial problem. Any help would be appreciated.