1
tableView
に1つおきに1つの色を塗りつぶす方法はありますか? tableView
のプロパティを調べてみましたが、何も見つかりませんでした。TableView他のすべてのセルの1つの色
私はこのようにそれをしたい:
tableview
cell - white
cell - gray
cell - white
cell - gray
等...
tableView
に1つおきに1つの色を塗りつぶす方法はありますか? tableView
のプロパティを調べてみましたが、何も見つかりませんでした。TableView他のすべてのセルの1つの色
私はこのようにそれをしたい:
tableview
cell - white
cell - gray
cell - white
cell - gray
等...
最も簡単な方法は、あなたのcellForRowAt
機能でプログラムこれを行うには次のようになります。
if indexPath.row % 2 == 0 {
cell.backgroundColor = UIColor.white
} else {
cell.backgroundColor = UIColor.gray
}
一行コード、必要ならば
cell.backgroundColor = indexPath.row % 2 == 0 ? .white : .gray
[代替カラーUITableViewCellはUITableViewにありますか?](https://stackoverflow.com/questions/30505330/color-alternate-uitableviewcell-in-a-uitableview) – ItsMeMihir