I had tried this code, I have also tried with stacks but not able to align with top .
I just want the view to appear on top with auto layout as like UIKit .
import SwiftUI
struct ItemDetail: View {
let item : MenuItem
var body: some View {
HStack(alignment: .top){
VStack{
Image(item.mainImage)
Text(item.description)
}
.padding(10)
.background(.red)
.navigationTitle(item.name)
}
}
}
struct ItemDetail_Previews: PreviewProvider {
static var previews: some View {
ItemDetail(item: MenuItem.example)
}
}
2
Answers
This should do it:
Swap the
HStack
for aVStack
and add aSpacer()
at the end. e.g.: