0% found this document useful (0 votes)
18 views

SwiftUI-1-Creating and Combining Views

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)
18 views

SwiftUI-1-Creating and Combining Views

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
You are on page 1/ 28

1.

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

struct ContentView: View {


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

.foregroundColor(.green)
}
}
Report

ContentView.swift
#Preview {
ContentView()
10
}
1.SwiftUI
11 - Creating and combining views import SwiftUI

struct ContentView: View {


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

}
}

#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

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
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

struct MapView: View {


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

#Preview {
Report

MapView()
}

22
1.SwiftUI
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 /

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()

Text("About Turtle Rock")


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

Spacer()
}
}
Marketing /

#Preview {
Report

ContentView()
}

28
ContentView.swift

You might also like