VNLunarCalendarView 0.1.4

VNLunarCalendarView 0.1.4

Hoang Anh Tuan维护。



  • Hoang Anh Tuan

VNLunarCalendarView

作者Ho Ngoc Duc的农历和阳历库参考算法

演示

GIF_Animation

安装

CocoaPods

使用CocoaPods,您可以简单地将VNLunarCalendarView添加到您的Podfile中
pod 'VNLunarCalendarView'
pod install

源文件

您可以将源文件夹下的所有文件复制到您的项目中。

使用

  • 在故事板中添加一个UIView,并将其类更改为VNLunarCalendarView 屏幕截图 2021-03-08 at 10 43 12

  • 将日历视图的出口和高度连接到.swift文件

  • 然后

import VNLunarCalendarView

Screen Shot 2021-03-08 at 10 50 00

  • 属性 屏幕截图 2021-03-08 at 16 12 52

示例

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
        }
    }
            
}