Bird
0
0

What will be the visible result of this SwiftUI code?

medium📝 Predict Output Q4 of 15
iOS Swift - SwiftUI Layout
What will be the visible result of this SwiftUI code?
Text("Hello")
  .background(Circle().fill(Color.red).frame(width: 100, height: 100))
AA red circle behind the text "Hello" with 100x100 size.
BA red circle overlaying the text "Hello" with 100x100 size.
COnly the text "Hello" with no background.
DA red square behind the text "Hello".
Step-by-Step Solution
Solution:
  1. Step 1: Understand .background() with a Circle

    The Circle view with red fill and fixed frame is placed behind the Text as background.
  2. Step 2: Confirm shape and size

    The shape is a circle, not a square, sized 100x100 points behind the text.
  3. Final Answer:

    A red circle behind the text "Hello" with 100x100 size. -> Option A
  4. Quick Check:

    Background places view behind = A red circle behind the text "Hello" with 100x100 size. [OK]
Quick Trick: Background places shapes behind text, overlay puts them on top [OK]
Common Mistakes:
  • Thinking background places view on top
  • Confusing circle with square shape
  • Ignoring frame size effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes