PDTSimpleCalendar 是一个基于 UICollectionView 的非常简单的日历/日期选择器组件,适用于您的 iOS 应用程序。
当您升级到较新版本时,应阅读 发布说明。
如果您不喜欢 cocapods 或 Carthage 或 Cocoapods-Rome,您仍然可以使用 git submodule
导入它,或者简单地将 PDTSimpleCalendar
中的所有源文件复制/粘贴到您的项目中。
firstDate
: 当日历必须开始时。如果您不指定任何内容,它将默认为当前月份的第一天(基于 [NSDate date]
)。如果 firstDate
不是该月的1号,则日历将显示整个月份,但日期 < firstDate
将被禁用。lastDate
: 当日历必须结束时。如果您不指定任何内容,它将默认为从 firstDate
开始的下一年最后一天。如果 lastDate
不是该月的最后一天,则日历将显示整个月份,但日期 > lastDate
将被禁用。calendar
: 用于显示和日期计算的日历。您可以为 NSCalendar
支持的任何日历设置。默认值将是 [NSCalendar currentCalendar]
。weekdayHeaderEnabled
: 如果启用,则会在日历顶部添加一个额外标题,显示星期。默认为 NO。weekdayTextType
: 如果启用了星期标题,您可以为标签自定义格式。 (Short(3个字母),VeryShort(1个字母),StandAlone(天完整名称))您可以使用 backgroundColor
和 overlayTextColor
属性在 PDTSimpleCalendarViewController
上更改日历的显示。
其他颜色可以使用 PDTSimpleCalendarViewCell
、PDTSimpleCalendarViewHeader
和 PDTSimpleCalendarViewWeekdayHeader
上的 UIAppearance 设置。
[[PDTSimpleCalendarViewCell appearance] setCircleDefaultColor:[UIColor whiteColor]];
[[PDTSimpleCalendarViewCell appearance] setCircleSelectedColor:[UIColor orangeColor]];
[[PDTSimpleCalendarViewCell appearance] setCircleTodayColor:[UIColor blueColor]];
[[PDTSimpleCalendarViewCell appearance] setTextDefaultColor:[UIColor redColor]];
[[PDTSimpleCalendarViewCell appearance] setTextSelectedColor:[UIColor purpleColor]];
[[PDTSimpleCalendarViewCell appearance] setTextTodayColor:[UIColor magentaColor]];
[[PDTSimpleCalendarViewCell appearance] setTextDisabledColor:[UIColor yellowColor]];
[[PDTSimpleCalendarViewHeader appearance] setTextColor:[UIColor redColor]];
[[PDTSimpleCalendarViewHeader appearance] setSeparatorColor:[UIColor orangeColor]];
[[PDTSimpleCalendarViewWeekdayHeader appearance] setHeaderBackgroundColor:[UIColor lightGrayColor]];
[[PDTSimpleCalendarViewWeekdayHeader appearance] setTextColor:[UIColor orangeColor]];
请查看示例,了解完整的 API 及更多自定义选项。
以下是它在 Producteev 应用程序中的外观
Copyright 2013-2015 Jive Software, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.