SwiftUI-1-Creating and Combining Views
SwiftUI-1-Creating and Combining Views
SwiftUI
1
Marketing /
Report
- Overview
1
1.SwiftUI
2
Marketing /
Report
- Overview
2
1.SwiftUI
3
Marketing /
Report
- Creating and combining views
3
1.SwiftUI
4 - Creating and combining views
Landmarks
Marketing /
Report
4
1.SwiftUI
5 - Creating and combining views
import SwiftUI
@main
struct LandmarksApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
import SwiftUI
LandmarksApp.swift
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
Marketing /
}
Report
#Preview {
ContentView()
}
5
ContentView.swift
1.SwiftUI
6
Marketing /
Report
- Creating and combining views
ContentView.swift
6
1.SwiftUI
7
Marketing /
Report
- Creating and combining views
7
1.SwiftUI
8
Marketing /
Report
- Creating and combining views
8
1.SwiftUI
9
Marketing /
Report
- Creating and combining views
1
1.SwiftUI
10 - Creating and combining views
import SwiftUI
.foregroundColor(.green)
}
}
Report
ContentView.swift
#Preview {
ContentView()
10
}
1.SwiftUI
11 - Creating and combining views import SwiftUI
}
}
#Preview {
ContentView.swift ContentView()
}
Marketing /
Report
11
1.SwiftUI
12
Marketing /
Report
- Creating and combining views
12
1.SwiftUI
13
Marketing /
Report
- Creating and combining views
13
import SwiftUI
1.SwiftUI
14 - Creating and combining views
struct ContentView: View {
var body: some View {
VStack {
Text("Turtle Rock")
.font(.title)
Text("Joshua Tree National
Park")
.font(.subheadline)
}
}
}
#Preview {
ContentView()
}
Marketing /
ContentView.swift
Report
14
import SwiftUI
1.SwiftUI
15 - Creating and combining views
struct ContentView: View {
var body: some View {
VStack(alignment: .leading) {
Text("Turtle Rock")
.font(.title)
HStack {
Text("Joshua Tree National
Park")
.font(.subheadline)
}
}
}
}
#Preview {
ContentView()
}
Marketing /
Report
ContentView.swift
15
1.SwiftUI
16 - Creating and combining views
import SwiftUI
.font(.subheadline)
Spacer()
Text("California")
.font(.subheadline)
}
}
.padding()
}
}
#Preview {
ContentView()
}
Marketing /
Report
16
1.SwiftUI
17
Marketing /
Report
- Creating and combining views
17
1.SwiftUI
18
Marketing /
Report
- Creating and combining views
18
import SwiftUI
1.SwiftUI
19 - Creating and combining views
struct CircleImage: View {
var body: some View {
Image("turtlerock")
.clipShape(Circle())
}
}
#Preview {
CircleImage()
}
Marketing /
CircleImage.swift
Report
19
import SwiftUI
1.SwiftUI
20 - Creating and combining views
struct CircleImage: View {
var body: some View {
Image("turtlerock")
.clipShape(Circle())
.overlay {
Circle().stroke(.white,
lineWidth: 4)
}
.shadow(radius: 7)
}
}
#Preview {
CircleImage()
}
Marketing /
CircleImage.swift
Report
20
1.SwiftUI
21
Marketing /
Report
- Creating and combining views
21
1.SwiftUI
22 - Creating and combining views
import SwiftUI
import MapKit
#Preview {
Report
MapView()
}
22
1.SwiftUI
23 - Creating and combining views import SwiftUI
import MapKit
#Preview {
MapView()
}
Marketing /
MapView.swift
Report
23
1.SwiftUI
24
Marketing /
Report
- Creating and combining views
24
import SwiftUI
1.SwiftUI
25 - Creating and combining views struct ContentView: View {
var body: some View {
VStack {
VStack(alignment: .leading) {
Text("Turtle Rock")
.font(.title)
HStack {
Text("Joshua Tree National Park")
.font(.subheadline)
Spacer()
Text("California")
.font(.subheadline)
}
}
.padding()
}
}
}
#Preview {
ContentView()
}
Marketing /
Report
ContentView.swift
25
import SwiftUI
1.SwiftUI
26 - Creating and combining views struct ContentView: View {
var body: some View {
VStack {
MapView()
.frame(height: 300)
CircleImage()
VStack(alignment: .leading) {
Text("Turtle Rock")
.font(.title)
HStack {
Text("Joshua Tree National Park")
.font(.subheadline)
Spacer()
Text("California")
.font(.subheadline)
}
}
.padding()
}
}
}
#Preview {
ContentView()
}
Marketing /
ContentView.swift
Report
26
import SwiftUI
1.SwiftUI
27 - Creating and combining views struct ContentView: View {
var body: some View {
VStack {
MapView()
.frame(height: 300)
CircleImage()
.offset(y: -130)
.padding(.bottom, -130)
VStack(alignment: .leading) {
Text("Turtle Rock")
.font(.title)
HStack {
Text("Joshua Tree National
Park")
.font(.subheadline)
Spacer()
Text("California")
.font(.subheadline)
}
}
.padding()
Spacer()
}
}
}
Marketing /
#Preview {
ContentView()
}
Report
ContentView.swift
27
import SwiftUI
1.SwiftUI
28 - Creating and combining views struct ContentView: View {
var body: some View {
VStack {
MapView()
.frame(height: 300)
CircleImage()
.offset(y: -130)
.padding(.bottom, -130)
VStack(alignment: .leading) {
Text("Turtle Rock")
.font(.title)
HStack {
Text("Joshua Tree National Park")
Spacer()
Text("California")
}
.font(.subheadline)
.foregroundStyle(.secondary)
Divider()
Spacer()
}
}
Marketing /
#Preview {
Report
ContentView()
}
28
ContentView.swift