[英]xcode swift cell detailTextLabel.text?. color taken from date
如果我的detailTextLabel.text中的“日期”早於今天,則我嘗試更改labelcolor。
// 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 == "01.04.2016 23:00" {
cell.detailTextLabel?.textColor = UIColor.redColor()
} else {
}
return cell
}
我怎樣才能做到這一點? 它適用於特定日期,但不適用於NSDate()或類似的東西。 我瘋了!
大哥!
如前所述,您可以執行以下操作:
...
let note = item.date
let now = NSDate()
if note.earlierDate(now).isEqualToDate(note) {
cell.detailTextLabel?.textColor = UIColor.redColor()
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.