Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a simple SwiftUI text view.
iOS Swift
Text([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string
Using a variable name without declaration
✗ Incorrect
The Text view in SwiftUI requires a string inside quotes to display text.
2fill in blank
mediumComplete the code to make the text bold in SwiftUI.
iOS Swift
Text("Welcome").[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
italic() insteadTrying to use
font() without parameters✗ Incorrect
The bold() modifier makes the text bold in SwiftUI.
3fill in blank
hardFix the error in the SwiftUI view declaration.
iOS Swift
struct ContentView: [1] { var body: some View { Text("Hi") } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using UIKit classes like UIView or UIViewController
Forgetting to conform to any protocol
✗ Incorrect
SwiftUI views conform to the View protocol, not UIKit classes.
4fill in blank
hardFill both blanks to create a vertical stack with two text views.
iOS Swift
VStack {
Text("Hello")[1]
Text("World")[2]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same modifier for both texts
Forgetting parentheses after modifiers
✗ Incorrect
The first Text has padding added, the second is made bold.
5fill in blank
hardFill all three blanks to create a button that prints a message when tapped.
iOS Swift
Button(action: [1]) { Text([2]) }.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Missing braces in action closure
Not quoting the button label
Forgetting parentheses after modifiers
✗ Incorrect
The button's action prints a message, the label shows "Tap me", and padding adds space around the button.