SwiftUI 视图中无法解释的差距
Unexplained Gap in SwiftUI View
我在两个视图元素之间看到一条白线,我无法解释。
以下代码为SwiftUI主视图
var body: some View {
NavigationView {
VStack {
TextField("Filter", text: $lastNameFilter)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding([.top, .leading, .trailing, .bottom])
.background(Color(UIColor.systemGroupedBackground))
FilteredList(filter: lastNameFilter)
} }
FilteredList 视图非常简单:
var body: some View {
List {
ForEach(fetchRequest, id: \.self) { recipient in
NavigationLink(destination:
ViewEventsView(recipient: recipient)) {
Text("\(recipient.wrappedFirstName) \(recipient.wrappedLastName)")
.foregroundColor(.green)
}
}
.onDelete(perform: deleteRecipient)
}
}
我试过使用和不使用填充,但这不是问题所在。 .padding 正在调整“过滤器”TextField 的插入。
任何指点将不胜感激。
这可能是 VStack 的默认间距。尝试将其更改为 VStack(spacing: 0)
.
我在两个视图元素之间看到一条白线,我无法解释。
以下代码为SwiftUI主视图
var body: some View {
NavigationView {
VStack {
TextField("Filter", text: $lastNameFilter)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding([.top, .leading, .trailing, .bottom])
.background(Color(UIColor.systemGroupedBackground))
FilteredList(filter: lastNameFilter)
} }
FilteredList 视图非常简单:
var body: some View {
List {
ForEach(fetchRequest, id: \.self) { recipient in
NavigationLink(destination:
ViewEventsView(recipient: recipient)) {
Text("\(recipient.wrappedFirstName) \(recipient.wrappedLastName)")
.foregroundColor(.green)
}
}
.onDelete(perform: deleteRecipient)
}
}
我试过使用和不使用填充,但这不是问题所在。 .padding 正在调整“过滤器”TextField 的插入。
任何指点将不胜感激。
这可能是 VStack 的默认间距。尝试将其更改为 VStack(spacing: 0)
.