Rohit Makwana
Rohit Makwana

Reputation: 4905

Extra Space in List (left and right side) SwiftUI

I am trying to create list screen but while creating a cell it drop a extra space right and left side.

I put only text for reference. I refer some link but it not helps me. and also tried other padding related modifier but not help it also to me.

image I attached space indicated with arrow

Upvotes: 1

Views: 1965

Answers (2)

iParesh
iParesh

Reputation: 2368

List drop a extra space right and left side, so you can use padding() modifier to resolve issue.

VStack(alignment: .leading) {

    List {

         Text("Hello stack work is going very fine. let's check the code is woking or not properly")
         .background(Color.blue)

         Text("Hello stack work is going very fine. let's check the code is woking or not properly")
         .background(Color.blue)
    }
   .foregroundColor(.white)
 }
 .padding(.leading, -16) // you can use as per your requirement(-16) 
 .padding(.trailing, -20)

Upvotes: 2

LuLuGaGa
LuLuGaGa

Reputation: 14418

The List adds a bit of padding on both sides, just like UITableView does. It generally helps readability, but if you insist on removing it, you can add

.padding(-10.0)

to your body.

Upvotes: 0

Related Questions