The calendar with support for:
Take a look at the example project over here
In order to create calendar with horizontal scroll direction:
VAMonthHeaderView
, it will represent the name of the month and the control buttons to switch between monthsVAWeekDaysView
, this view will display weekdays namesfirstWeekday
andtimeZone
to correctly display dateslet defaultCalendar: Calendar = {
var calendar = Calendar.current
calendar.firstWeekday = 1
calendar.timeZone = TimeZone(secondsFromGMT: 0)!
return calendar
}()
VAMonthHeaderView
and VAWeekDaysView
@IBOutlet weak var monthHeaderView: VAMonthHeaderView! {
didSet {
let appereance = VAMonthHeaderViewAppearance(
previousButtonImage: #imageLiteral(resourceName: "previous"),
nextButtonImage: #imageLiteral(resourceName: "next"),
dateFormat: "LLLL"
)
monthHeaderView.delegate = self
monthHeaderView.appearance = appereance
}
}
@IBOutlet weak var weekDaysView: VAWeekDaysView! {
didSet {
let appereance = VAWeekDaysViewAppearance(symbolsType: .veryShort, calendar: defaultCalendar)
weekDaysView.appearance = appereance
}
}
VACalendarView
var calendarView: VACalendarView!
override func viewDidLoad() {
super.viewDidLoad()
let calendar = VACalendar(calendar: defaultCalendar)
calendarView = VACalendarView(frame: .zero, calendar: calendar)
calendarView.showDaysOut = true
calendarView.selectionStyle = .multi
calendarView.monthDelegate = monthHeaderView
calendarView.dayViewAppearanceDelegate = self
calendarView.monthViewAppearanceDelegate = self
calendarView.calendarDelegate = self
calendarView.scrollDirection = .horizontal
view.addSubview(calendarView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if calendarView.frame == .zero {
calendarView.frame = CGRect(
x: 0,
y: weekDaysView.frame.maxY,
width: view.frame.width,
height: view.frame.height * 0.6
)
calendarView.setup()
}
}
Version 1.0
Version 1.3
use_frameworks!
pod 'VACalendar'
VACalendar
is released under an MIT License. See LICENSE
for details.