Lesson 3 Flashcards

SwiftUI Grab Bag

1
Q

Text in SwiftUI

A

Text (text element) –> built in text styles, environment based modifiers (changes specific text)

built in styles support many modifiers
(.font, .fontWeight, .lineLimit, etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

why use built in text styles?

A
  1. Dynamic type
  2. Bold text
  3. semantic names –> consistency across app
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Color in SwiftUI

A

similar to Text –> built in colors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

why use built in colors?

A
  1. light and dark mode –> adapt to light and dark mode easily
  2. increase contrast
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how are colors easily used by SwiftUI?

A

color conforms to view (can be used anywhere)
access defaults as static properties (Color.primary, Color.secondary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

default colors good for text

A

.primary –> default
.secondary

^ adapt to light and dark mode by default

primary text light mode –> black
primary text dark mode –> white

secondary is gray in both

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are the bounds of the safe area?

A

views stay within safe area by default –> from below battery, etc bar to above home swipe bar (between dynamic island and home indicator)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

why is there a safe area?

A

makes sure content isn’t obscured

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

how would you ignore this safe area to cover the whole screen?

A

.ignoresSafeArea() (on desired view)
.background(_:ignoresSafeArea:)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

two main kinds of swift images

A
  1. SF Symbols –> builtin symbol library
  2. Custom images –> imported into Assets catalog
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how to declare SF Symbol

A

Image(systemName: “symbol name”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what are SF Symbols used for?

A

icons

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how to use custom image

A

Image(.nameOfImage)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what size are custom images by default?

A

their true size, declared width and height in pixels –> probably very large or very small depending on quality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how would you resize image?

A

.resizable() // this
.scaledToFit() // or this
.frame(width: #, height: #) //optional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

clip shape

A

allows you to customize the shape of your views (images)

17
Q

Image(.oldWell)
.resizable()
.clipShape(.rect(cornerRadius: 16))

what does this do?

A

clips the image of the old well to be in a rectangular shape with rounded corners by size 16