I have a fairly simple view that consists of a tile and below it a horizontal scrollview. This display with a large gap between the title and the scrollview and I want the title sitting on top of the scrollview -- maybe 2 or 4 point gap. The current gap looks like 80 points or so.
Code:
let section: Section
let userLevel: Int
let stringsViewModel: StringsViewModel
let onItemSelected: (AudioItem) -> Void
var body: some View {
VStack(alignment: .leading, spacing: 0) {
Text(section.title)
.font(.system(size: 18, weight: .medium))
.foregroundColor(.white)
.padding(.leading, 16)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(section.items, id: \.titleKey) { item in
MeditationItemView(audioItem: item, userLevel: userLevel, stringsViewModel: stringsViewModel)
.onTapGesture {
onItemSelected(item)
}
}
}
.padding(.leading, 0)
.padding(.trailing, 16)
}
}
.padding(.leading, 16)
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI