- iOS 9.0+
- Xcode 8+
To install add the following line to your Podfile
:
pod 'JKCalendar'
To install add the following line to your Cartfile
:
github "JoeCiou/JKCalendar"
Firstley, import JKCalendar
import JKCalendar
Then, there are to two ways you can create JKCalendar:
- By storyboard, change class of any
UIView
to JKCalendar
Note: Set Module to JKCalendar
.
- By code, using initializer.
let calendar = JKCalendar(frame: frame)
public enum JKCalendarMarkType{
case circle
case hollowCircle
case underline
case dot
}
For single mark: For continuous mark:
Firstley, Setup data source:
calendar.dataSource = self
For single mark:
func calendar(_ calendar: JKCalendar, marksWith month: JKMonth) -> [JKCalendarMark]? {
let today = JKDay(date: Date())
if today == month{
return [JKCalendarMark(type: .underline, day: today, color: UIColor.red)]
}else{
return nil
}
}
For continuous mark:
func calendar(_ calendar: JKCalendar, continuousMarksWith month: JKMonth) -> [JKCalendarContinuousMark]?{
let markStartDay = JKDay(year: 2017, month: 9, day: 3)!
let markEndDay = JKDay(year: 2017, month: 9, day: 12)!
if markStartDay == month || markEndDay == month{
return [JKCalendarContinuousMark(type: .circle, start: markStartDay, end: markEndDay, color: UIColor.red)]
}else{
return nil
}
}
The MIT License (MIT)
copyright (c) 2017 Joe Ciou