0
0
iOS Swiftmobile~10 mins

Modifier chaining in iOS Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the text color to red using modifier chaining.

iOS Swift
Text("Hello World")[1](.red)
Drag options to blanks, or click blank then click option'
A.foregroundColor
B.font
C.background
D.padding
Attempts:
3 left
💡 Hint
Common Mistakes
Using .background instead of .foregroundColor
Forgetting the dot before the modifier
Using .font instead of color modifier
2fill in blank
medium

Complete the code to add padding around the text using modifier chaining.

iOS Swift
Text("Welcome")[1]()
Drag options to blanks, or click blank then click option'
A.fontWeight
B.background
C.frame
D.padding
Attempts:
3 left
💡 Hint
Common Mistakes
Using .frame instead of .padding
Forgetting parentheses after the modifier
Using .background instead of padding
3fill in blank
hard

Fix the error in the code by completing the modifier chain to make the text bold.

iOS Swift
Text("SwiftUI")[1]()
Drag options to blanks, or click blank then click option'
A.italic
B.bold
C.underline
D.strikethrough
Attempts:
3 left
💡 Hint
Common Mistakes
Using .italic instead of .bold
Forgetting parentheses after the modifier
Using .underline which only adds underline
4fill in blank
hard

Fill both blanks to chain modifiers that set the font size to title and the text color to blue.

iOS Swift
Text("Hello")[1](.title)[2](.blue)
Drag options to blanks, or click blank then click option'
A.font
B.foregroundColor
C.background
D.padding
Attempts:
3 left
💡 Hint
Common Mistakes
Using .background instead of .foregroundColor
Swapping the order of modifiers incorrectly
Using .padding instead of font or color
5fill in blank
hard

Fill all three blanks to chain modifiers that add padding, set the background color to yellow, and make the text italic.

iOS Swift
Text("Swift")[1]()[2](.yellow)[3]()
Drag options to blanks, or click blank then click option'
A.padding
B.background
C.italic
D.bold
Attempts:
3 left
💡 Hint
Common Mistakes
Using .bold instead of .italic
Forgetting parentheses after modifiers
Mixing order of modifiers