我嘗試改變labelcolor採取的顏色,如果在我的detailTextLabel.text「約會」前輩那麼今天..xcode swift cell detailTextLabel.text ?.從日期
// 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()或類似的東西。我瘋了!
大thx!
檢查這個http://stackoverflow.com/questions/26807416/check-if-date-is-before-current-date-swift和請確保與相同的格式 –
比較顯然你的Item.date是字符串格式,所以不可能直接與NSDate對象進行比較。 – sleepwalkerfx