Bird
0
0

What will be the font weight of the text shown by this SwiftUI code?

medium📝 Predict Output Q5 of 15
iOS Swift - SwiftUI Basics
What will be the font weight of the text shown by this SwiftUI code?
Text("SwiftUI")
  .fontWeight(.light)
  .fontWeight(.heavy)
AHeavy
BLight
CRegular
DBold
Step-by-Step Solution
Solution:
  1. Step 1: Understand fontWeight modifier behavior

    Like other modifiers, the last fontWeight call overrides previous ones.
  2. Step 2: Analyze the code

    The first .fontWeight(.light) is overridden by .fontWeight(.heavy).
  3. Final Answer:

    Heavy -> Option A
  4. Quick Check:

    Last fontWeight modifier applies = B [OK]
Quick Trick: Last fontWeight modifier sets the weight [OK]
Common Mistakes:
  • Assuming first fontWeight applies
  • Confusing fontWeight with font size
  • Ignoring modifier order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes