1

I want to change the background white to an another color to the List in SwiftUI

Click Here

List(listOfItems) { item in
    Group {
        HStack {
            item.iconImage.padding()
            Text(item.text).fontWeight(.regular).foregroundColor(Color("smalltext")).font(.system(size: 25))
            Spacer()
            Button(action: {
                
            }) {
                Image("back")
            }
        }.padding().background(Color("bg"))
    }.listRowBackground(Color("bg"))
}.background(Color("bg"))

1 Answer 1

4

If you want to change the background color you would do the following in the view containing the List. Add this init block in your View. This will change everything to green.

init() {
   UITableViewCell.appearance().backgroundColor = .green
   UITableView.appearance().backgroundColor = .green
}
Sign up to request clarification or add additional context in comments.

1 Comment

didnt work for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.