Swe*_*per 1 colors uitableview ios swift
我的应用程序的主题颜色是绿色,所以一切都必须是绿色,就像这个表视图单元格:
问题是,当我单击"编辑"按钮时,单元格左侧会弹出一个小的减号,而不是绿色:
我不明白为什么会这样.这是我的代码cellForRowAtIndexPath
let cell = UITableViewCell()
cell.textLabel?.text = someStuff
cell.textLabel?.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
cell.contentView.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
// Look! here I set the color of the editing accessory!
cell.editingAccessoryView?.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
return cell
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我将所有内容都设置为绿色,包括文本标签,背景,甚至是editingAccessoryView
!但那件事不是绿色的!如上所示,它保持白色.
还有什么我必须设置为绿色?
你必须在tableView:willDisplayCell:forRowAtIndexPath:
方法中这样做.你可以这样:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = "MyText"
return cell
}
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
}
Run Code Online (Sandbox Code Playgroud)
编辑:
归档时间: |
|
查看次数: |
1396 次 |
最近记录: |