我正在尝试使用这个 calendar component我的任务是在今天之前的所有日期在视觉上和技术上使残疾人成为残疾人。用户也可以在月份之间切换,我需要禁用今天之前的所有日期,即使它是几年前的日期。 disabledDateTextColor
和 disabledDateBackgroundColor
类型也为此日历定义,但没有日期计算方法。我正在阅读 NSDate
文档,看起来我不能直接这样做,使用系统方法(我的意思是方法返回日期之前或之后的日期数组或类似的东西)。看起来像将今天之前的所有现有日期添加到 NSArray
并在绘制日历之前将它们标记为禁用是一个明显的矫枉过正,不是吗?
最佳答案
在我之前的申请中我使用了这个方法
switch ([dateOne compare:dateTwo]) {
case NSOrderedAscending:
// dateOne is earlier in time than dateTwo
break;
case NSOrderedSame:
// The dates are the same
break;
case NSOrderedDescending:
// dateOne is later in time than dateTwo
break;
}
两个日期格式应该是相似的 阅读下面链接中的实例方法以获取更多信息
关于ios - NSDate。抓取今天之前的所有日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17991361/