SwiftUI Stack Alignment Quiz

Take this quiz to test your knowledge of VStack, HStack, and ZStack alignment in SwiftUI.

1. 
What happens when you apply an alignmentGuide() modifier to a view in a VStack?

2. 
Which alignment option is unique to HStack and not shared with VStack?

3. 
Which alignment option is not available for HStack?

4. 
In a VStack, how are child views aligned?

5. 
What object is passed to the closure in an alignmentGuide() modifier to assist in calculating the alignment?

6. 
What will happen if the alignment type in an alignmentGuide() modifier does not match the alignment type applied to the parent stack?

7. 
What is the result of using d.width / 3 in an alignmentGuide() modifier?

8. 
What must an enum conform to when creating a custom alignment type?

9. 
What is the impact of using the following modifier in a VStack?

Rectangle().
    alignmentGuide(.leading, computeValue: { d in d.width / 2 })

10. 
How do you define a new alignment type in SwiftUI?

11. 
Which of the following is true about SwiftUI’s standard alignment types?

12. 
Which layout system uses both horizontal and vertical alignment to arrange its views?

13. 
What does the alignment guide closure return?

14. 
Alignments guides are positioned relative to which of following?

15. 
Which of the following is a valid way to extend the set of standard alignment types in SwiftUI?

16. 
What will happen if no alignment is specified in an HStack?

17. 
If you want to align views based on a specific text baseline, which SwiftUI stack should you use?

18. 
Which alignment option would align the child views of a VStack along the trailing edge?

19. 
What is the default alignment for child views in an HStack?

20. 
Which modifier is used to apply a custom alignment in SwiftUI?

21. 
When applying a custom alignment guide, what is passed to the closure to help compute the alignment position?

22. 
Which alignment type aligns child views based on the baseline of the last text view?

23. 
How does SwiftUI handle a view within a VStack if no alignment guide is applied?

24. 
Which modifier is used to apply spacing between views in an HStack?

25. 
What does the function within a custom alignment enum need to return?

26. 
How does ZStack align child views by default?

27. 
What is the main purpose of using alignment guides in SwiftUI?

28. 
Which object provides access to HorizontalAlignment and VerticalAlignment properties within an alignment guide?

29. 
What does the defaultValue() function in a custom alignment enum typically do?

30. 
Which modifier would you use to align views within a ZStack using a custom alignment?

31. 
Which of the following is required to create a custom alignment?

32. 
In the context of cross-stack alignment, what must be done to align views from different stacks?

33. 
How is a custom alignment applied to a view?

34. 
What must be included in a custom alignment to align views horizontally and vertically?

35. 
Which of the following is a key advantage of using custom alignments in SwiftUI?

36. 
What happens when custom alignments are applied to child views within a VStack?

37. 
Which modifier helps adjust the space between child views in a stack?

38. 
Which property is used to create vertical alignment options in SwiftUI?

39. 
What must be done to calculate a view's custom alignment position?

Congratulations on completing the SwiftUI Stack Alignment Quiz.

Click the Submit button to review your results.

Enter your email address below if you would like to receive a copy of your test results.


Categories