I would like to add subviews to my VStack from bottom to top manner. By default VStack fills from Center only. I tried by giving Y Offset to subview but that doesn't generate output as expected.
Please find my code sample as below:
import SwiftUI
let colors = [Color.red, Color.green, Color.blue, Color.yellow]
struct DiskView: View {
let id:Int!
var body: some View {
ZStack{
colors[id]
Text("\(id)").foregroundColor(.white)
}
}
}
struct TowerView: View {
func hanoiTapped(){
}
var body: some View {
ZStack{
Image("hanoi_pillaar").gesture(TapGesture().onEnded({ _ in
hanoiTapped()
}))
VStack() {
DiskView(id:2).frame(width:50, height:10)
DiskView(id:1).frame(width:50, height:10)
}
}
}
}
struct ContentView: View {
var body: some View {
VStack {
Text("Hello, world!")
HStack{
TowerView().padding()
}
}.padding()
}
}
I used logic of 180 degree roatation as suggeste at How to fill SwiftUI's VStack from bottom to top with items, but it doesn't address my issue. It mirrors items of list.