Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a Text view that displays "Hello, SwiftUI!".
iOS Swift
Text([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the quotes around the string
Passing a Text view inside another Text view
✗ Incorrect
The Text view requires a string literal inside quotes to display text.
2fill in blank
mediumComplete the code to make the Text view bold using a modifier.
iOS Swift
Text("Welcome!").[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using .italic() instead of .bold()
Trying to pass parameters to .bold()
✗ Incorrect
The .bold() modifier makes the text bold.
3fill in blank
hardFix the error in the code to change the text color to red.
iOS Swift
Text("Error Fix").foregroundColor([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string "red" instead of Color.red
Using UIKit UIColor instead of SwiftUI Color
✗ Incorrect
In SwiftUI, colors are specified using the Color struct, like Color.red.
4fill in blank
hardFill both blanks to create a Text view with font size 24 and italic style.
iOS Swift
Text("Stylish Text").font(.system(size: [1])).[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using .bold() instead of .italic()
Passing font size as a string
✗ Incorrect
Use .font(.system(size: 24)) to set size and .italic() to make text italic.
5fill in blank
hardFill all three blanks to create a Text view with blue color, bold font, and underline.
iOS Swift
Text("Decorated").foregroundColor([1]).[2]().[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using .italic() instead of .underline()
Using string "blue" instead of Color.blue
✗ Incorrect
Use Color.blue for color, .bold() for bold text, and .underline() for underline.