Complete the code to center the text inside the VStack.
VStack {
Text("Hello, SwiftUI!")
.frame(maxWidth: .infinity, alignment: [1])
}Using .center aligns the text horizontally in the center of the available space.
Complete the code to add horizontal spacing of 20 points between elements in the HStack.
HStack(spacing: [1]) { Text("One") Text("Two") Text("Three") }
Setting spacing: 20 adds 20 points of space between each element horizontally.
Fix the error in the code to add vertical padding of 15 points to the Text view.
Text("Welcome") .padding([1], 15)
Using .vertical adds padding only to top and bottom (vertical direction).
Fill both blanks to create a VStack with spacing 10 and align its content to the leading edge.
VStack(spacing: [1], alignment: [2]) { Text("Item 1") Text("Item 2") }
Spacing 10 adds space between items vertically. Alignment .leading aligns content to the left.
Fill all three blanks to create a Text view with padding 12, background color blue, and corner radius 8.
Text("Button") .padding([1]) .background(Color.[2]) .clipShape(RoundedRectangle(cornerRadius: [3]))
Padding 12 adds space inside the Text. Background color blue colors behind the text. Corner radius 8 rounds the corners.