Changing the Color of Cells

Asked 1 years ago, Updated 1 years ago, 383 views

List{
Text ("Text")
.listRowBackground (Color.black)
}

in

The color does not change.

swift swiftui

2022-12-28 06:05

1 Answers

The code itself is correct, so please try something other than black.It may be hard to understand.

https://www.motokis-brain.com/article/28

import SwiftUI

struct ContentView:View {

    varbody:someView {

        List{
            Text ("Test 1")
                .listRowBackground (Color.red)
            Text ("Test 2" )
                .listRowBackground (Color.blue)
            Text ("Test 3")
                .listRowBackground (Color.green)
            Text ("Test 4")
                .listRowBackground (Color.gray)
            Text ("Test 5")
                .listRowBackground (Color.yellow)
        }
    }
}


2022-12-28 07:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.