[ad_1]
To begin with playground instance that demonstrates the issue:
import UIKit
import SwiftUI
import PlaygroundSupport
struct MyList: View {
var physique: some View {
content material
}
personal var content material: some View {
Checklist {
Part {
Textual content("whats up")
}
.background(Shade.crimson) // This solely modifications small space round textual content. Searching for Workaround 2
}
.background(Shade.blue) // This does not work (Workaround 1)
.foregroundColor(Shade.yellow)
}
init() {
// Workaround 1 - works
UITableView.look().backgroundColor = .blue
// Workaround 2 - nothing under helps
UITableView.look().sectionIndexTrackingBackgroundColor = .inexperienced
UITableView.look().sectionIndexBackgroundColor = .inexperienced
UITableViewCell.look().backgroundColor = .inexperienced
UITableViewCell.look().backgroundView = nil
UITableViewCell.look().backgroundConfiguration = .clear()
}
}
let viewController = UIHostingController(rootView: MyList())
// Current the view controller within the Reside View window
PlaygroundPage.present.liveView = viewController
Rationalization:
Viewhas aChecklist, which I would like to alter background for. There is a well-known workaround to alter it by way ofUITableView.look().backgroundColor, which is what I do. Thus far so good.- I additionally want to alter the background of the part. Within the picture under I would like the whole part to be crimson, not white. White mustn’t exist in any respect:
However I can not discover the way in which to realize this. If I add .background(Shade.crimson) to the Part, it solely modifications the small space across the textual content. OK, but when the white space is just not a part of Checklist, and never Part then what’s the remainder of the white space?
I attempted varied workarounds present in SO, as listed below // Workaround 2 - nothing under helps. None of them assist.
So my query is, merely put, how do I do away with white space on this structure.
Notice:
- I would favor to not swap away from Checklist, except it is the one possibility.
- Solutions involving introspect are nice too.
[ad_2]

