I've implemented a vertical scroll view (using List
) containing two horizontal scroll views (using ScrollView
s). The UI currently looks like this:
Here's the relevant code I've written to produce above UI:
NavigationView {
List {
VStack(alignment: .leading) {
CategoryRow(...)
CategoryRow(...)
Spacer()
}
.listRowInsets(EdgeInsets())
.navigationBarTitle(Text("Featured"))
}
}
Inside each CategoryRow
, there's an HStack
embedded inside a ScrollView
.
When introducing a padding on the left & right edges, I get this result:
As you can see, as a result of the padding, the horizontal scroll views are cut-off.
Is there a way to have the horizontal scroll views over-scroll past their boundaries?
The result I am looking for is that there is padding on the left of the scroll views when the scroll offset is 0 and padding on the right when the scrolling all the way to the right.
In UIKit, I did this by setting the contentOffset of the collection view...
Add the padding
modifier to your HStack inside the RowView
.padding(.horizontal, 20)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With