Search code examples
swiftswiftuiios16

SwipeAction not changeing color with .tint() modifier


List{
            Button{
                //Checking in
            }label: {
                Text("Check in")
                    .swipeActions {
                        Button{
                           //Checking in
                        }label: {
                            Text("Check in")
                        }.tint(.red)
                    }
            }
        }

I've tried to change the color of the background when swiping on a row. Nothing happens. It just keeps being the standard gray.

enter image description here

I've looked at a bunch of other people and it seems like they all put the modifier at the same place as me but they get a different result.


Solution

  • Add .buttonStyle(.plain) to the Button in the List:

    List {
        Button {
            //Checking in
        } label: {
            Text("Check in")
                .swipeActions {
                    Button {
                        //Checking in
                    } label: {
                        Text("Check in")
                    }
                    .tint(.red)
                }
        }
        .buttonStyle(.plain)            
    }