Complete the code to create a vertical ScrollView in SwiftUI.
ScrollView([1]) { Text("Hello, ScrollView!") }
The ScrollView direction is set using .vertical to scroll vertically.
Complete the code to add padding inside the ScrollView content.
ScrollView(.vertical) {
Text("Scrollable content")
.[1](20)
}Use padding(20) to add space inside the content area.
Fix the error in the ScrollView code to make it compile.
ScrollView(.vertical) {
VStack {
Text("Item 1")
Text("Item 2")
}[1]
}Adding .padding() after VStack is valid and compiles correctly.
Fill both blanks to create a horizontal ScrollView with spacing between items.
ScrollView([1]) { HStack(spacing: [2]) { Text("A") Text("B") Text("C") } }
Use .horizontal for horizontal scrolling and 10 for spacing between items.
Fill all three blanks to create a ScrollView with a VStack that has padding and a background color.
ScrollView(.vertical) {
VStack {
Text("Hello")
Text("World")
}[1]([2])
.[3](Color.gray.opacity(0.2))
}Use padding(30) to add space inside VStack and background to set a light gray background color.
