VNLunarCalendarView
作者Ho Ngoc Duc的农历和阳历库参考算法
演示
安装
CocoaPods
使用CocoaPods,您可以简单地将VNLunarCalendarView
添加到您的Podfile中
pod 'VNLunarCalendarView'
pod install
源文件
您可以将源文件夹下的所有文件复制到您的项目中。
使用
import VNLunarCalendarView
示例
import UIKit
import VNLunarCalendarView
class ViewController: UIViewController {
@IBOutlet weak var lunarCalendarView: VNLunarCalendarView!
@IBOutlet weak var heightOfLunarCalendarView: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
lunarCalendarView.delegate = self
lunarCalendarView.setCurrentMonth(month: 3, year: 2021)
lunarCalendarView.setWeekdayTitle(weekdayTitle: ["T2", "T3", "T4", "T5", "T6", "T7", "CN"])
lunarCalendarView.setBackgroundColor(.white)
lunarCalendarView.setBackgroundCurrentDay(#colorLiteral(red: 1, green: 0.9725490196, blue: 0.9411764706, alpha: 1))
lunarCalendarView.setBackgroundDateSelectedColor(.yellow)
lunarCalendarView.setBorderColorDay(color: .gray, borderWidth: 0.5)
lunarCalendarView.setBorderColorDaySelected(color: .orange, borderWidth: 2)
lunarCalendarView.setHeightOfDayView(height: 50)
lunarCalendarView.setWeekdayTitleColor(color: .black)
lunarCalendarView.setTextDayColor(textSolarDayOfCurrentMonthColor: .black, textLunarDayOfCurrentMonthColor: #colorLiteral(red: 0.9803921569, green: 0.5725490196, blue: 0.2, alpha: 1), textSolarDayNotInCurrentMonthColor: #colorLiteral(red: 0.7960784314, green: 0.7960784314, blue: 0.7960784314, alpha: 1), textLunarDayNotInCurrentMonthColor: #colorLiteral(red: 1, green: 0.8078431373, blue: 0.6274509804, alpha: 1))
}
}
extension ViewController: VNLunarCalendarViewDelegate {
func dateDidSelect(_ solarDay: Int, _ solarMonth: Int, _ solarYear: Int, _ lunarDay: Int, _ lunarMonth: Int, _ lunarYear: Int) {
lunarCalendarView.setCurrentlySelectedDate(solarDay, solarMonth, solarYear)
}
func monthAndYearIsShowing(_ month: Int, _ year: Int) {
print("Month and year is showing: \(month)/\(year)")
}
func numberOfRowInCalendarView(_ row: Int) {
switch row {
case 4:
self.heightOfLunarCalendarView.constant = 231
case 5:
self.heightOfLunarCalendarView.constant = 281
case 6:
self.heightOfLunarCalendarView.constant = 331
default:
return
}
}
}