What Is a View?
Learn the View protocol and the body computed property.
What Is a View? is a free SwiftUI Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the SwiftUI Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Everything Is a View
In SwiftUI, almost everything you see on screen is a view. Text, images, buttons, and even your whole screen are all views. 📱
The View Protocol
A view is any type that conforms to the View protocol. Conforming means you promise to describe what should appear on screen.
struct ContentView: View {
var body: some View {
Text("Hello!")
}
}Views Are Structs
Most SwiftUI views are simple structs. They are lightweight value types, so SwiftUI can create and discard them cheaply as your UI changes.
The body Requirement
The View protocol has one job for you: provide a body property. It is where you describe the view's content.
struct ContentView: View {
var body: some View {
Text("Welcome")
}
}body Is Computed
The body is a computed property, not stored. SwiftUI reads it whenever it needs to redraw, so it always reflects your latest code.
What some View Means
The return type some View says body returns one specific view type, but you do not have to spell out which. The compiler figures it out.
var body: some View {
Text("Opaque type magic")
}One View, Many Pieces
A single view's body often combines many smaller views. The whole arrangement is still treated as one view from the outside. 🧩
Views Describe, Not Draw
You never paint pixels yourself. A view simply describes what it wants, and SwiftUI decides how to render it efficiently.
Views Are Cheap and Disposable
Because views are value types, SwiftUI recreates them constantly. Do not store heavy work in a view; keep its body fast and simple.
Composing Custom Views
You build your app by writing your own custom views. Each one is a struct conforming to View, just like the built-in ones.
struct GreetingView: View {
var body: some View {
Text("Hi there")
}
}Reusing Your Views
Once you define a view, you can drop it anywhere just by its name. This reuse keeps your UI consistent and your code tidy.
var body: some View {
GreetingView()
}Quick Check
Let's confirm what makes a type a SwiftUI view.
Recap: What Is a View?
A view is a struct that conforms to View and provides a body of type some View. Views describe content, are cheap, and compose into your whole UI. 🎉
Frequently asked questions
Is the “What Is a View?” lesson free?
Yes — the full text of “What Is a View?” is free to read here on the web, and the SwiftUI Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the SwiftUI Academy course, upgrade to CoddyKit PRO.
What will I learn in “What Is a View?”?
Learn the View protocol and the body computed property. You practise SwiftUI Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start SwiftUI Academy?
No prior experience is required. SwiftUI Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “What Is a View?” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this SwiftUI Academy lesson?
Yes. Every SwiftUI Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.