Bird
0
0

What does the foregroundColor modifier do when applied to a Text view in SwiftUI?

easy📝 Conceptual Q1 of 15
iOS Swift - SwiftUI Basics
What does the foregroundColor modifier do when applied to a Text view in SwiftUI?
AChanges the font style of the text
BChanges the color of the text displayed
CChanges the background color of the view
DAdds a shadow effect to the text
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of foregroundColor

    The foregroundColor modifier sets the color of the text or foreground content in SwiftUI.
  2. Step 2: Differentiate from other modifiers

    It does not affect background color, font style, or shadows, which have their own modifiers.
  3. Final Answer:

    Changes the color of the text displayed -> Option B
  4. Quick Check:

    foregroundColor changes text color = C [OK]
Quick Trick: foregroundColor changes text color, not background or font [OK]
Common Mistakes:
  • Confusing foregroundColor with backgroundColor
  • Thinking it changes font style
  • Assuming it adds effects like shadows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes