YYCalendar 1.3.3

YYCalendar 1.3.3

DevYeom维护。



  • 作者:
  • DevYeom

YYCalendar

Swift Version License Platform

介绍

当您需要让用户从日历中选择日期时,可以使用YYCalendar。简单明了😎

示例

要运行示例项目,请先克隆仓库,然后在示例目录中运行pod install

Demo

用法

要创建和显示日历,首先在文件开头导入模块

import YYCalendar

首先,您可以将日历显示如下

您必须将日期参数的format与格式参数相等。

let calendar = YYCalendar(normalCalendarLangType: .ENG, date: "07/01/2019", format: "MM/dd/yyyy") { date in
    print(date)
}

calendar.show()

您可以设置日历样式属性(颜色、字体等)

calendar.dayButtonStyle = DayButtonStyle (.roundishSquare, .square, .circle)
calendar.dimmedBackgroundColor = UIColor
calendar.dimmedBackgroundAlpha = CGFloat
calendar.headerViewBackgroundColor = UIColor
calendar.bodyViewBackgroundColor = UIColor
calendar.sundayColor = UIColor
calendar.disabledSundayColor = UIColor
calendar.saturdayColor = UIColor
calendar.disabledSaturdayColor = UIColor
calendar.defaultDayColor = UIColor
calendar.disabledDefaultDayColor = UIColor
calendar.lineSeparatorColor = UIColor
calendar.selectedDayColor = UIColor
calendar.headerLabelFont = UIFont
calendar.weekLabelFont = UIFont
calendar.dayLabelFont = UIFont

日历类型

有两种类型的日历。

日历类型 描述
普通 您可以选择所有日期范围
有限 您可以限制可选的日期范围
// normal type
init(normalCalendarLangType langType: LangType, date: String, format: String, completion: @escaping SelectHandler)

// limited type
init(limitedCalendarLangType langType: LangType, date: String, minDate: String?, maxDate: String?, format: String, completion: @escaping SelectHandler)

normalType_Sample limitedType_Sample

语言类型

可以通过选择langType来更改星期标签。

langType weekLabel
ENG 日, 一, 二, 三, 四, 五, 六
ENG2 周日, 周一, 周二, 周三, 周四, 周五, 周六
ENG3 S, M, T, W, T, F, S
KOR 일, 월, 화, 수, 목, 금, 토
JPN 日, 月, 火, 水, 木, 金, 土
CHN 日, 一, 二, 三, 四, 五, 六
自定义 [String]

ENG_Sample ENG2_Sample ENG3_Sample KOR_Sample JPN_Sample CHN_Sample

您可以根据以下方式指定自定义星期标签。

let weekArray = ["1", "2", "3", "4", "5", "6", "7"]
let calendar = YYCalendar(normalCalendarLangType: .custom(weekArray), date: "07/01/2019", format: "MM/dd/yyyy") { date in
    print(date)
}

calendar.show()

安装

YYCalendar可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile

pod 'YYCalendar'

作者

DevYeom, [email protected]

许可证

YYCalendar遵循MIT许可证。有关更多信息,请参阅LICENSE文件。