Reputation: 4905
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.
Code
.......
let text = "Hello stack work is going very fine. let's check the code is woking or not properly"
var body: some View {
List {
Text(text).background(Color.blue)
Text(text).background(Color.blue)
}.foregroundColor(.white)
}
.....
image I attached space indicated with arrow
Upvotes: 1
Views: 1965
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
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