Reputation: 519
Nested horizontal ScrollView has invisible padding from the top. I've tried to add ".padding(.top, 0)" for the ScrollView and for the content, but it doesn't work. Is it a bug or it is possible to remove this padding?
VStack(alignment: .leading) {
Text("Text one")
Text("Text two")
ScrollView(.horisontal, showsIndicators: false) {
Text("Text with strange top padding")
}
}.padding(.horizontal)
Upvotes: 3
Views: 4724
Reputation: 257533
I don't know what is ScrollingView
but with standard ScrollView
provided example works well (tested with Xcode 11.2 / iOS 13.2)
Here is a demo with added border around scroll view for better visibility
struct TestHorizontalScrollView: View {
var body: some View {
VStack(alignment: .leading, spacing: 0) {
Text("Text one")
Text("Text two")
ScrollView(.horizontal) {
Text("Text with strange top padding")
}.border(Color.red)
}.padding(.horizontal)
}
}
Upvotes: 4