Michael Rowe
Michael Rowe

Reputation: 956

Unexplained Gap in SwiftUI View

I am seeing a white line between two of my view elements, that I cannot explain. Filtered List View

The following cod is the main SwiftUI View

 var body: some View {
    NavigationView {
        VStack {
            TextField("Filter", text: $lastNameFilter)
                .textFieldStyle(RoundedBorderTextFieldStyle())
                .padding([.top, .leading, .trailing, .bottom])
                .background(Color(UIColor.systemGroupedBackground))
            FilteredList(filter: lastNameFilter)
        } }

The FilteredList view is very simple:

    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)
    }
}

I have tried with and without padding, but that is not the issue. The .padding, is adjusting the inset of the "filter" TextField.

Any pointers would be appreciated.

Upvotes: 1

Views: 49

Answers (1)

Mateus Rodrigues
Mateus Rodrigues

Reputation: 36

That's probably the default spacing of the VStack. Try changing it to VStack(spacing: 0).

Upvotes: 2

Related Questions