SwiftUI/Lists
How to set the background color of list rows using listRowBackground()
까칠코더
2019. 11. 20. 13:22
반응형
Hacking with Swift 사이트의 강좌 번역본입니다.
How to set the background color of list rows using listRowBackground()
SwiftUI는 list 행 뒤에 있는 배경 뷰를 설정하는 listRowBackground()현태로 된, 전용 modifier을 가지고 있습니다. 이것은 모든 종류의 뷰를 받아들이고(색상, 이미지, 도형을 포함) 행의 뒤에서 사용합니다.
예를들어, 10개의 행을 사용하는 list를 만들고, 각각 빨간 배경색을 사용합니다.
List {
ForEach(0..<10) {
Text("Row \($0)")
}
.listRowBackground(Color.red)
}
팁 : listRowBackground()는 list에 데이터가 없는 것에는 영향을 주지 않습니다.
반응형