0% found this document useful (0 votes)
49 views28 pages

SwiftUI: Creating Views Overview

Uploaded by

Tâm Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views28 pages

SwiftUI: Creating Views Overview

Uploaded by

Tâm Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

SwiftUI
1
Marketing /
Report
- Overview

1
[Link]
2
Marketing /
Report
- Overview

2
[Link]
3
Marketing /
Report
- Creating and combining views

3
[Link]
4 - Creating and combining views

Landmarks
Marketing /
Report

4
[Link]
5 - Creating and combining views
import SwiftUI

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

import SwiftUI
[Link]
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
Marketing /

}
Report

#Preview {
ContentView()
}
5
[Link]
[Link]
6
Marketing /
Report
- Creating and combining views

[Link]
6
[Link]
7
Marketing /
Report
- Creating and combining views

7
[Link]
8
Marketing /
Report
- Creating and combining views

8
[Link]
9
Marketing /
Report
- Creating and combining views

1
[Link]
10 - Creating and combining views

import SwiftUI

struct ContentView: View {


var body: some View {
Text("Turtle Rock")
.font(.title)
Marketing /

.foregroundColor(.green)
}
}
Report

[Link]
#Preview {
ContentView()
10
}
[Link]
11 - Creating and combining views import SwiftUI

struct ContentView: View {


var body: some View {
Text("Turtle Rock")
.font(.title)

}
}

#Preview {
[Link] ContentView()
}
Marketing /
Report

11
[Link]
12
Marketing /
Report
- Creating and combining views

12
[Link]
13
Marketing /
Report
- Creating and combining views

13
import SwiftUI
[Link]
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 /

[Link]
Report

14
import SwiftUI
[Link]
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

[Link]
15
[Link]
16 - Creating and combining views
import SwiftUI

struct ContentView: View {


var body: some View {
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

16
[Link]
17
Marketing /
Report
- Creating and combining views

17
[Link]
18
Marketing /
Report
- Creating and combining views

18
import SwiftUI
[Link]
19 - Creating and combining views
struct CircleImage: View {
var body: some View {
Image("turtlerock")
.clipShape(Circle())
}
}

#Preview {
CircleImage()
}
Marketing /

[Link]
Report

19
import SwiftUI
[Link]
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 /

[Link]
Report

20
[Link]
21
Marketing /
Report
- Creating and combining views

21
[Link]
22 - Creating and combining views

import SwiftUI
import MapKit

struct MapView: View {


var body: some View {
Text("Hello, World!")
}
}
Marketing /

#Preview {
Report

MapView()
}

22
[Link]
23 - Creating and combining views import SwiftUI
import MapKit

struct MapView: View {


var body: some View {
Map(initialPosition:
.region(region))
}

private var region: MKCoordinateRegion


{
MKCoordinateRegion(
center:
CLLocationCoordinate2D(latitude:
34.011_286, longitude: -116.166_868),
span:
MKCoordinateSpan(latitudeDelta: 0.2,
longitudeDelta: 0.2)
)
}
}

#Preview {
MapView()
}
Marketing /

[Link]
Report

23
[Link]
24
Marketing /
Report
- Creating and combining views

24
import SwiftUI

[Link]
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

[Link]
25
import SwiftUI

[Link]
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 /

[Link]
Report

26
import SwiftUI

[Link]
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

[Link]
27
import SwiftUI

[Link]
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()

Text("About Turtle Rock")


.font(.title2)
Text("Descriptive text goes here.")
}
.padding()

Spacer()
}
}
Marketing /

#Preview {
Report

ContentView()
}

28
[Link]

You might also like