嗨,我是 JTAppleCalendar 的新手。我需要帮助。我已经通过 cocoapods 安装了它,并使用了如下的一些代码。
我需要有关如何使用基本功能的帮助,例如:
- 设置当前月份的日历
JTC.scrollToDate(日期())
在日历上显示当前日期。
我是否需要指定或配置此日历支持多少年,例如 100 年或 200 年?
获取 JTAppleCalendar 参考的这种方式是否正确
@IBOutlet 弱变量 JTC:JTAppleCalendarView!
请帮助更正代码。
import UIKit
import JTAppleCalendar
class ViewController: UIViewController {
let formatter = DateFormatter()
@IBOutlet weak var JTC: JTAppleCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
let d = Date()
var dateArr = [Date]()
dateArr.append(d)
JTC.scrollToDate(Date())
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension ViewController: JTAppleCalendarViewDelegate,JTAppleCalendarViewDataSource{
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
formatter.dateFormat = "yyyy MM dd"
formatter.timeZone = Calendar.current.timeZone
formatter.locale = Calendar.current.locale
let startDate = formatter.date(from: "2017 01 01")!
let endDate = formatter.date(from: "2117 12 31")!
let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate)
return parameters
}
func calendar(_ calendar:JTAppleCalendarView,cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell{
let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "CustomCell", for: indexPath) as! CustomCell
cell.dateLabel.text = cellState.text
return cell
}
}
谢谢