Bird
0
0

What does Spacer() do in a SwiftUI layout?

easy📝 Conceptual Q11 of 15
iOS Swift - SwiftUI Basics
What does Spacer() do in a SwiftUI layout?
AIt adds a border around the view.
BIt adds a fixed amount of space around a view.
CIt changes the color of the background.
DIt creates flexible empty space that expands to fill available space.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Spacer's role

    Spacer() is used to create flexible space that grows to fill available space inside stacks.
  2. Step 2: Compare with padding

    Padding adds fixed space around views, but Spacer expands flexibly to push views apart.
  3. Final Answer:

    It creates flexible empty space that expands to fill available space. -> Option D
  4. Quick Check:

    Spacer = flexible space [OK]
Quick Trick: Spacer expands space flexibly, padding adds fixed space [OK]
Common Mistakes:
  • Confusing Spacer with padding
  • Thinking Spacer adds fixed space
  • Assuming Spacer changes colors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes