Reputation: 4190
How do I change only the background of the yellow button so it doesn't have that white background coming from the form?
Here's what I have:
NavigationView {
Form {
Section(header: Text("Display"),
footer: Text("System settings ...")) {
Toggle(isOn: .constant(true),
label: {
Text("Dark Mode")
})
}
Section {
Label("Follow me ...", systemImage: "link")
}
Section {
Button(action: {
}) {
Text("Unlock PRO")
}
Button(action: {
}) {
Text("Restore purchase")
}
}
Section {
Button(action: {
authSessionManager.signOut()
}) {
Text("Sign Out!")
.font(.footnote)
.fontWeight(.semibold)
.foregroundColor(.black)
.multilineTextAlignment(.center)
.padding()
.frame(width: 300, height: 40)
.background(Color.orange)
.cornerRadius(15.0)
}
.padding(.top)
}
.listRowBackground(Color.clear)
}
.navigationTitle("Settings")
}
this is how it looks:
And this is what I've tried:
.listRowBackground(Color.clear)
I put that at the end but makes not difference. Any idea?
NOTE: I'm not trying to remove the background of all cells like here, I just need 1.
I would prefer a SwiftUI native solution if possible.
Upvotes: 4
Views: 556
Reputation: 4190
I figured it out, all I had to do was add at the end of a stack the following:
.listRowBackground(Color(UIColor.systemGroupedBackground))
Upvotes: 3