I created a app with SwiftUI I have used this code to layout my view
struct ContentView: View {
var body: some View {
List(0 ..< 5) { item in
VStack {
Text("Hello World")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundColor(Color.red)
Image("Hello")
.aspectRatio(contentMode: .fit)
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
but VStack is not fit to contentView
Just add.resizable() to your Image.
wrap a ScrollView{} around it.
struct ContentView: View {
var body: some View {
List(0 ..< 5) { item in
ScrollView{
VStack {
Text("Hello World")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundColor(Color.red)
Image("Hello")
.aspectRatio(contentMode: .fit)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.