A Comprehensive List of SwiftUI Views: The Building Blocks of Swift UI
I’ve compiled this list to serve as a reference that you can save and refer back to any time for a refresher on syntax or inspiration for ways to build out your views. I hope it helps!
SwiftUI is built around a variety of views that enable developers to compose complex interfaces using simple and intuitive code. In this article, we’ll explore a comprehensive list of SwiftUI views, along with brief descriptions and code examples to showcase their usage.
- Text:
A view that displays a piece of static text.
Text(“Hello, World!”)
2. Image:
A view that displays an image or system icon.
Image("imageName")
3. Button:
A view that represents a tappable button.
Button("Tap Me") {
// Action to perform on button tap
}
4. TextField:
A view that allows user input with a single line of text.
TextField("Enter your name", text: $name)
5. SecureField:
A view that allows secure user input (passwords).
SecureField("Enter your password", text: $password)