Bird
0
0

What will be the color of the text displayed by this code?

medium📝 ui behavior Q13 of 15
iOS Swift - SwiftUI Basics
What will be the color of the text displayed by this code?
Text("Welcome")
  .foregroundColor(.red)
  .foregroundColor(.blue)
ARed
BPurple
CBlue
DBlack (default)
Step-by-Step Solution
Solution:
  1. Step 1: Understand modifier chaining order

    Modifiers apply in order; the last .foregroundColor overrides previous ones.
  2. Step 2: Identify final color

    The last color set is .blue, so the text color will be blue.
  3. Final Answer:

    Blue -> Option C
  4. Quick Check:

    Last modifier wins = Blue [OK]
Quick Trick: Last color modifier sets the text color [OK]
Common Mistakes:
  • Thinking colors combine or blend
  • Assuming first modifier applies
  • Ignoring modifier order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes