Skip to content
Go back

Day 1 of iOS (SwiftUI): Project Structure and What Padding Really Means

Edit page

What I Did Today

SwiftUI Project Structure (The Basic Idea)

A SwiftUI app usually starts in a file like MyApp.swift:

@main
struct WeSplitApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

What this means:

What Is ContentView?

ContentView is a SwiftUI view:

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "gearshape")
            Text("Hello, world!")
        }
    }
}

body describes the UI. SwiftUI reads body and draws the screen.

The Main Confusion: What Does .padding() Do?

At first, padding looked like “making things bigger,” but the real meaning is:

Think of it this way:

Why Did It Look Like the Content Got Bigger?

I wrote code like this:

VStack {
    // content
}
.padding(50)
.border(.red)

The border is drawn after padding, so it includes the padding area. The red border gets larger, which makes it feel like the whole view grew.

The Key Trick: Order Matters

1) Padding first, then border

.padding(50)
.border(.red)

2) Border first, then padding

.border(.red)
.padding(50)

This simple ordering difference is the easiest way to understand what padding really does.


Edit page
Share this post on:

Next Post
Starting My iOS and SEO Learning Journey