SwiftUI Tutorial: Working with Form

Create a simple note taking app that changes appearance

Arc Sosangyo
Geek Culture

--

Figure 1.

Form in SwiftUI is a struct that works like a container for categorizing controls. Initially, the standard use of Form is to have a dedicated view for requiring certain input to users. One example is a shopping app that ask for payment and shipping information via Form. But since Form is basically just a container, it is also popularly used for Settings which is what we’re going to do in this tutorial.

This article is part of my SwiftUI Tutorial series.

Starting with the basics first in order for you to understand how a Form view works. So make sure you already have an open project for practice. You can use this link if you need a step-by-step process on how to do it.

Turn your ContentView into this:

struct ContentView: View {

var body: some View {

VStack {

Form {
Text("Hello World")
}

Form {
Text("Hello Earth")
Text("Hello Mars")
}

Form {
Section {
Text("Hello Sun")
}
Section {
Text("Hello Moon")
}
}…

--

--

Arc Sosangyo
Geek Culture

Arc is an iOS developer and app publisher, a former IT manager who transitioned to iOS engineering, and a big fan of coding, science, history, and philosophy.