Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a Text view inside a VStack.
Swift
VStack {
[1]("Hello, SwiftUI!")
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Button or Image instead of Text to show text.
✗ Incorrect
The Text view displays a string in SwiftUI. Inside a VStack, you use Text to show text.
2fill in blank
mediumComplete the code to add a Button with a label inside a VStack.
Swift
VStack {
Button(action: {
print("Clicked")
}) {
[1]("Tap me")
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using VStack or Spacer inside the Button label.
✗ Incorrect
The Button label is usually a view like Text that shows the button's title.
3fill in blank
hardFix the error in the code by completing the VStack content with multiple views.
Swift
VStack {
Text("Hello")
[1]("World")
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Button or Image where Text is expected.
✗ Incorrect
To show multiple text lines inside a VStack, use multiple Text views.
4fill in blank
hardFill both blanks to create a VStack with a Text and a Button label.
Swift
VStack {
[1]("Welcome")
Button(action: {}) {
[2]("Click here")
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Image or Spacer instead of Text.
✗ Incorrect
The VStack contains a Text view and a Button with a Text label.
5fill in blank
hardFill all three blanks to create a VStack with a Text, an Image, and a Button label.
Swift
VStack {
[1]("Hello")
[2](systemName: "star.fill")
Button(action: {}) {
[3]("Press")
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up Image and Text or using Spacer incorrectly.
✗ Incorrect
The VStack contains a Text view, an Image with a system icon, and a Button with a Text label.