Reputation: 51
I am using SwiftUI for creating tab in iPhone. However it has creating extra tabs when I am trying to add two VStack in body.
'''
struct DemoView: View {
var body: some View {
VStack {
Text("This is bug")
}
VStack { //2nd Vstack
Text("This is bug")
}
}
}
'''
for this 2nd VStack its creating two Demo tab [![enter image description here][1]][1]
My code to write TabBar [1]: https://i.sstatic.net/qEoKn.png
Upvotes: 0
Views: 70
Reputation: 647
You are not supposed to have multiple children in the body. you can put everything in either a VStack, HStack, Group, ZStack, or something of that sort depending on what you are trying to accomplish.
For example, if you want the 2 VStacks to be stacked vertically, you can wrap them all in a VStack like so:
struct DemoView: View {
var body: some View {
VStack{
VStack {
Text("This is bug")
}
VStack { //2nd Vstack
Text("This is bug")
}
}
}
}
Upvotes: 2