0
0
iOS Swiftmobile~5 mins

Spacer and padding in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Spacer in SwiftUI?
A Spacer is a flexible space that expands to fill available space in a layout, pushing other views apart.
Click to reveal answer
beginner
How does padding affect a view in SwiftUI?
Padding adds empty space around the content inside a view, creating space between the view's edges and its content.
Click to reveal answer
beginner
Which SwiftUI modifier adds space inside a view's border?
The .padding() modifier adds space inside the view's border, around its content.
Click to reveal answer
intermediate
What happens if you add multiple Spacers in a horizontal stack?
Multiple Spacers share the available space equally, pushing views evenly apart.
Click to reveal answer
intermediate
Can you specify padding only on certain edges in SwiftUI?
Yes, you can specify padding on specific edges using .padding(.leading), .padding(.top), etc.
Click to reveal answer
What does Spacer() do in a SwiftUI layout?
AAdds flexible empty space to push views apart
BAdds a fixed-size box
CAdds padding inside a view
DCreates a border around a view
How do you add padding only to the top of a view in SwiftUI?
A.padding(10)
B.padding(.top)
C.padding(.all)
D.padding(.leading)
If you want equal space between three buttons horizontally, what should you use?
AUse .background() modifier
BAdd padding to each button
CAdd Spacer() between each button
DUse .frame(width: 100) on buttons
What is the default behavior of .padding() without parameters?
AAdds padding only on the bottom
BAdds padding only on the left
CRemoves all padding
DAdds equal padding on all sides
Which of these is NOT true about Spacer()?
AIt adds fixed padding inside a view
BMultiple Spacers share space equally
CIt can expand to fill space
DIt helps align views in stacks
Explain how Spacer and padding work together to create balanced layouts in SwiftUI.
Think about how empty space and inside space affect view placement.
You got /4 concepts.
    Describe how you would add space only on the left side of a button in SwiftUI.
    Remember padding can target specific edges.
    You got /3 concepts.