KVKCalendar allows deep customization of its UI components through the CalendarDataSource protocol.
Custom Event Views
To provide a custom view for specific events, subclass EventViewGeneral and implement the willDisplayEventView(_:frame:date:) method in your data source.
Custom Date Cells
To customize date cells (for Day, Week, Month, or Year views) or list cells, implement the dequeueCell<T>(parameter:type:view:indexPath:) method in your data source. This method allows you to dequeue and configure custom cells from UICollectionView or UITableView.
// Custom Event View
class CustomViewEvent: EventViewGeneral {
override init(style: Style, event: Event, frame: CGRect) {
super.init(style: style, event: event, frame: frame)
}
}
// In your CalendarDataSource implementation
func willDisplayEventView(_ event: Event, frame: CGRect, date: Date?) -> EventViewGeneral? {
if event.ID == targetID {
return CustomViewEvent(style: style, event: event, frame: frame)
}
return nil
}
// Custom Cell Dequeuing
func dequeueCell<T>(parameter: CellParameter, type: CalendarType, view: T, indexPath: IndexPath) -> KVKCalendarCellProtocol? where T: UIScrollView {
switch type {
case .year:
return (view as? UICollectionView)?.dequeueCell(indexPath: indexPath) { (cell: CustomYearCell) in
// configure cell
}
case .day, .week, .month:
return (view as? UICollectionView)?.dequeueCell(indexPath: indexPath) { (cell: CustomDayCell) in
// configure cell
}
case .list:
return (view as? UITableView)?.dequeueCell { (cell: CustomListCell) in
// configure cell
}
}
}