Bird
0
0

You want to create a SwiftUI view where three colored squares overlap each other with red on bottom, green in middle, and blue on top. Which stack and order of views achieves this?

hard📝 Application Q15 of 15
iOS Swift - SwiftUI Basics
You want to create a SwiftUI view where three colored squares overlap each other with red on bottom, green in middle, and blue on top. Which stack and order of views achieves this?
AZStack { Color.red Color.green Color.blue } with Color.blue last
BVStack { Color.red Color.green Color.blue } with Color.red last
CHStack { Color.blue Color.green Color.red } with Color.red last
DZStack { Color.blue Color.green Color.red } with Color.red last
Step-by-Step Solution
Solution:
  1. Step 1: Choose stack for overlapping views

    ZStack layers views on top of each other, perfect for overlapping.
  2. Step 2: Order views for correct layering

    In ZStack, last view is top layer, so Color.blue last puts blue on top, red first puts red at bottom.
  3. Final Answer:

    ZStack { Color.red Color.green Color.blue } with Color.blue last -> Option A
  4. Quick Check:

    ZStack layering order = last view on top [OK]
Quick Trick: Use ZStack; last view is top layer [OK]
Common Mistakes:
  • Using VStack or HStack for overlapping
  • Reversing order of colors in ZStack
  • Thinking first view is top layer in ZStack

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes