Bird
0
0

What will happen if you use geometry.size.height inside a GeometryReader when the container height is 500 points?

medium📝 ui behavior Q5 of 15
iOS Swift - SwiftUI Layout
What will happen if you use geometry.size.height inside a GeometryReader when the container height is 500 points?
GeometryReader { geometry in
  Text("Height: \(geometry.size.height)")
}
AThe text will display "Height: 0"
BThe text will display "Height: nil"
CThe text will cause a compile error
DThe text will display "Height: 500"
Step-by-Step Solution
Solution:
  1. Step 1: Understand geometry.size.height

    It reflects the container's height, which is 500 points.
  2. Step 2: Text interpolation

    The text shows the height value as a string.
  3. Final Answer:

    The text will display "Height: 500" -> Option D
  4. Quick Check:

    geometry.size.height shows container height [OK]
Quick Trick: geometry.size.height shows container height value [OK]
Common Mistakes:
  • Assuming height is zero by default
  • Expecting a compile error
  • Thinking height can be nil

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes