I'm a beginner (started a week ago) in SwiftUI and trying out different things with app development. I'm stuck with Zstack not being able to execute anything. This is multiplatform app, and when I simulate it, it's just blank white space. When I erase zstack, and just run with vstack, it does the same thing.
Asked
Active
Viewed 627 times
1 Answers
1
It looks like you have created an app that is not based on SwiftUI but based on UIKit.
When creating your app make sure that you choose the following options:
- Interface: SwiftUI
- Life Cycle: SwiftUI App
Then looking in the Project Navigator you should see something like this:
You should then put your SwiftUI code inside the ContentView.swift
struct ContentView: View {
var body: some View {
ZStack {
VStack {
LinearGradient(
gradient: Gradient(colors: [.green, .white, .blue]),
startPoint: .topLeading,
endPoint: .bottomTrailing
)
.edgesIgnoringSafeArea(.all)
}
}
}
}
Which would give you something like this:
If you are a beginner with SwiftUI then I suggest that you look at some tutorials, hackingwithswift.com is a good place to start.

Andrew
- 26,706
- 9
- 85
- 101