Bird
0
0

What does the .background() modifier do in SwiftUI?

easy📝 Conceptual Q1 of 15
iOS Swift - SwiftUI Layout
What does the .background() modifier do in SwiftUI?
AIt places a view on top of the current view as an overlay.
BIt changes the text color of the view.
CIt places a view behind the current view as a background.
DIt removes the current view from the screen.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of .background()

    The .background() modifier adds a view behind the current view, acting as a background layer.
  2. Step 2: Differentiate from .overlay()

    The .overlay() modifier places a view on top of the current view, not behind it.
  3. Final Answer:

    It places a view behind the current view as a background. -> Option C
  4. Quick Check:

    Background modifier = places view behind [OK]
Quick Trick: Background puts view behind, overlay puts view on top [OK]
Common Mistakes:
  • Confusing background with overlay
  • Thinking background changes text color
  • Assuming background removes the view

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes