0
0
iOS Swiftmobile~5 mins

Alignment and spacing in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of alignment in iOS Swift UI layout?
Alignment controls how views are positioned relative to each other or their container, such as left, center, or right alignment.
Click to reveal answer
beginner
How does spacing affect UI elements in SwiftUI?
Spacing adds empty space between UI elements to improve readability and visual balance.
Click to reveal answer
beginner
Which SwiftUI container uses alignment and spacing parameters to arrange child views horizontally?
HStack arranges child views horizontally and lets you set alignment and spacing between them.
Click to reveal answer
beginner
What does the .padding() modifier do in SwiftUI?
.padding() adds space around a view’s content, pushing it away from neighboring views or edges.
Click to reveal answer
intermediate
How can you align text to the center inside a VStack in SwiftUI?
Set the VStack's alignment to .center or use the .multilineTextAlignment(.center) modifier on the Text view.
Click to reveal answer
Which SwiftUI container arranges views vertically with optional spacing?
AList
BHStack
CZStack
DVStack
What does the spacing parameter control in an HStack?
AThe space between the HStack and its parent
BThe space between child views inside the HStack
CThe padding inside each child view
DThe alignment of child views
How do you add space around a view in SwiftUI?
AUse .padding() modifier
BUse .frame() modifier
CUse .background() modifier
DUse .offset() modifier
Which alignment option centers views horizontally in a VStack?
A.center
B.trailing
C.leading
D.top
What does the ZStack do in SwiftUI?
AArranges views horizontally
BArranges views vertically
CStacks views on top of each other
DCreates a list of views
Explain how alignment and spacing work together to create a clean UI layout in SwiftUI.
Think about how you arrange items on a shelf with equal gaps and lined up edges.
You got /4 concepts.
    Describe how you would center a text label inside a vertical stack with some space around it.
    Imagine placing a sign in the middle of a shelf with some empty space around it.
    You got /3 concepts.