我有以下代码:变化的UITableView单元格颜色
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if (self.from! == "Hello") {
println("Hello")
cell.backgroundColor = UIColor.redColor()
cell.textLabel?.textColor = UIColor.yellowColor()
} else {
println("Not Hello")
cell.backgroundColor = UIColor.yellowColor()
cell.textLabel?.textColor = UIColor.redColor()
}
}
的问题是,它适用于整个表 - 我只是想改变创建的最后一个单元格。
有什么想法?
什么是你的表中的数据源?数组? – Shades