Boš*_*tar 3 static tableview ios8 xcode6.1
我有静态表,我设置了背景颜色tableview -> tableView.backgroundColor = UIColor.redColor(),当我有等时。静态表中有 3 行然后是 tableview 颜色,3 行是白色如何修复此单元格的背景颜色?此代码不适用于静态表 ->
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
cell.textLabel!.text = numbers[indexPath.row]
cell.backgroundColor = UIColor.greenColor()
return cell
}
Run Code Online (Sandbox Code Playgroud)
小智 6
在静态表视图中,您不必实现 cellForRowAtIndexPath。所以我建议你实现以下代码:
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
// Change the color of all cells
cell.backgroundColor = UIColor.greenColor()
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8357 次 |
| 最近记录: |