【发布时间】:2016-04-04 17:21:55
【问题描述】:
我想将我的表格视图中的行颜色更改为红色。如果日期(副标题)从今天起超过 5 天。我尝试了类似的方法:(文本字段颜色的示例)
// Configure the cell...
cell.textLabel?.textColor = UIColor.blueColor()
cell.detailTextLabel?.textColor = UIColor.darkGrayColor()
let item = frc.objectAtIndexPath(indexPath) as! Item
cell.textLabel?.text = item.name! + "-" + item.etage! + "-" + item.raum!
let note = item.date
cell.detailTextLabel!.text = "\(note!)"
if note == "04.04.2016 20:31:55" {
cell.detailTextLabel?.textColor = UIColor.redColor()
} else {
}
return cell
}
它可以工作..但只有准确的时间(分钟,秒)。 我怎样才能做到这一点,只比较一天减去 5 天?
【问题讨论】:
-
当问题陈述很简单时,很难提供解决方案,“它不起作用”。请edit您的问题更完整地描述您预期会发生什么以及这与实际结果有何不同。请参阅 How to Ask 以获取有关什么是好的解释的提示。
标签: swift uitableview date row