Bird
0
0

In SwiftUI, what happens if you apply .frame(width: 100, height: 100) to a Text view?

easy📝 Conceptual Q1 of 15
iOS Swift - SwiftUI Layout
In SwiftUI, what happens if you apply .frame(width: 100, height: 100) to a Text view?
AThe Text view is constrained to 100x100 points size.
BThe Text view ignores the frame and sizes to its content.
CThe Text view becomes invisible.
DThe Text view expands to fill the parent view.
Step-by-Step Solution
Solution:
  1. Step 1: Understand frame modifier effect on views

    The frame modifier sets the size constraints for the view it is applied to.
  2. Step 2: Apply fixed width and height to Text

    Setting width and height to 100 forces the Text view to be exactly 100x100 points.
  3. Final Answer:

    The Text view is constrained to 100x100 points size. -> Option A
  4. Quick Check:

    frame modifier sets size = B [OK]
Quick Trick: Frame sets exact size constraints on views [OK]
Common Mistakes:
  • Thinking frame only affects background color
  • Assuming Text ignores frame size
  • Confusing frame with padding

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes