GDCalendar
支持RTL/LTR语言的Calendar组件,启用Swiping Gesture导航。
易于使用,支持Storyboard和Attributes Inspector。
需求
- Xcode 10+
- Swift 4+
- iOS 8+
安装
CocoaPods
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'GDCalendar'
end
pod update
pod install
使用
import GDCalendar
设置所需区域格式的日历
// Persian Calendar Locale: fa_IR
UserDefaults.standard.set("fa_IR", forKey: "current_locale")
// List of available iOS locale names
// https://gist.github.com/jacobbubu/1836273
/*
If `current_locale` is not set, default phone calendar will be selected
*/
代码
let calendar = GDTextSlot(frame: view.bounds)
view.addSubview(calendar)
设置属性
// Days view items color
calendar.headerItemColor = UIColor.white
// Main calendar items text color
calendar.itemsColor = UIColor.black
// Header view items font
calendar.headersFont = UIFont.boldSystemFont(ofSize: 13)
// Calendar items font
calendar.itemsFont = UIFont.systemFont(ofSize: 15)
// Full properties list can be found on sample project
设置日期选择闭包
calendar.dateSelectHandler = { [weak self] selectedDate in
print(selectedDate)
// Get Date Components
let day = date.dayName
let month = date.monthName
let components = date.componentsOfDate
print("\(components.year) / \(components.month) / \(components.day)")
}
故事板
- 将
UIView
添加到故事板中,将自定义类设置为GDCalendar
- 使用
属性检查器
设置属性
许可证
GDCalendar 在 MIT 许可证下可用。更多信息请参阅 LICENSE.txt 文件。