CreationKit Documentation

Class JTACMonth​View

open class JTACMonthView: UICollectionView  
JTACMonthView JTACMonthView UICollectionViewDataSource UICollectionViewDataSource JTACMonthView->UICollectionViewDataSource UIScrollViewDelegate UIScrollViewDelegate JTACMonthView->UIScrollViewDelegate UICollectionView UICollectionView JTACMonthView->UICollectionView UICollectionViewDelegate UICollectionViewDelegate JTACMonthView->UICollectionViewDelegate

Conforms To

UICollectionView
UICollectionViewDataSource
UICollectionViewDelegate
UIScrollViewDelegate

Initializers

init()

public init()  

Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.

init(frame:​collection​View​Layout:​)

@available(*, unavailable, message: "Please use JTAppleCalendarMonthView() instead. It manages its own layout.")
    public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout)  

Initializes and returns a newly allocated collection view object with the specified frame and layout.

init?(coder:​)

required public init?(coder aDecoder: NSCoder)  

Initializes using decoder object

Properties

cell​Size

@IBInspectable open var cellSize: CGFloat = 0  

Configures the size of your date cells

selected​Cells

open var selectedCells: (first: (date: Date, indexPath: IndexPath)?, last:  (date: Date, indexPath: IndexPath)?) 

Stores the first and last selected date cel

scroll​Direction

open var scrollDirection: UICollectionView.ScrollDirection = .horizontal

The scroll direction of the sections in JTAppleCalendar.

cached​Configuration

open var cachedConfiguration: ConfigurationParameters?  

The configuration parameters setup by the developer in the confogureCalendar function

allows​Date​Cell​Stretching

open var allowsDateCellStretching = true

Enables/Disables the stretching of date cells. When enabled cells will stretch to fit the width of a month in case of a <= 5 row month.

is​Range​Selection​Used

@available(*, unavailable, renamed: "allowsRangedSelection")
    open var isRangeSelectionUsed: Bool = false

Alerts the calendar that range selection will be checked. If you are not using rangeSelection and you enable this, then whenever you click on a datecell, you may notice a very fast refreshing of the date-cells both left and right of the cell you just selected.

allows​Ranged​Selection

open var allowsRangedSelection: Bool = false

range​Selection​Mode

open var rangeSelectionMode: RangeSelectionMode = .segmented

calendar​Delegate

weak open var calendarDelegate: JTACMonthViewDelegate?  

The object that acts as the delegate of the calendar view.

calendar​Data​Source

weak open var calendarDataSource: JTACMonthViewDataSource?  

The object that acts as the data source of the calendar view.

section​Inset

open var sectionInset: UIEdgeInsets  

minimum​Interitem​Spacing

open var minimumInteritemSpacing: CGFloat  

minimum​Line​Spacing

open var minimumLineSpacing: CGFloat  

scrolling​Mode

open var scrollingMode: ScrollingMode = .stopAtEachCalendarFrame  

Configure the scrolling behavior

semantic​Content​Attribute

open override var semanticContentAttribute: UISemanticContentAttribute  

A semantic description of the view’s contents, used to determine whether the view should be flipped when switching between left-to-right and right-to-left layouts.

ib​Calendar​Delegate

@IBOutlet public var ibCalendarDelegate: AnyObject?  

Workaround for Xcode bug that prevents you from connecting the delegate in the storyboard. Remove this extra property once Xcode gets fixed.

ib​Calendar​Data​Source

@IBOutlet public var ibCalendarDataSource: AnyObject?  

Workaround for Xcode bug that prevents you from connecting the delegate in the storyboard. Remove this extra property once Xcode gets fixed.

delegate

@available(*, unavailable)
    /// Will not be used by subclasses
    open override var delegate: UICollectionViewDelegate?  

data​Source

@available(*, unavailable)
    /// Will not be used by subclasses
    open override var dataSource: UICollectionViewDataSource?  

selected​Dates

open var selectedDates: [Date]  

Returns all selected dates

Methods

collection​View(_:​view​For​Supplementary​Element​OfKind:​at:​)

public func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView  

Asks your data source object to provide a supplementary view to display in the collection view.

collection​View(_:​will​Display:​for​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)  

collection​View(_:​did​Highlight​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath)  

Tells the delegate that the item at the specified index path was highlighted.

collection​View(_:​did​Unhighlight​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, didUnhighlightItemAt indexPath: IndexPath)  

Tells the delegate that the item at the specified index path was unhighlighted.

collection​View(_:​cell​For​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell  

Asks your data source object for the cell that corresponds to the specified item in the collection view.

number​OfSections(in:​)

public func numberOfSections(in collectionView: UICollectionView) -> Int  

Asks your data sourceobject for the number of sections in the collection view. The number of sections in collectionView.

collection​View(_:​number​OfItems​InSection:​)

public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int  

Asks your data source object for the number of items in the specified section. The number of rows in section.

collection​View(_:​should​Select​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool  

Asks the delegate if the specified item should be selected. true if the item should be selected or false if it should not.

collection​View(_:​should​Deselect​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, shouldDeselectItemAt indexPath: IndexPath) -> Bool  

Asks the delegate if the specified item should be deselected. true if the item should be deselected or false if it should not.

collection​View(_:​did​Select​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)  

Tells the delegate that the item at the specified index path was selected. The collection view calls this method when the user successfully selects an item in the collection view. It does not call this method when you programmatically set the selection.

collection​View(_:​did​Deselect​Item​At:​)

public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)  

Tells the delegate that the item at the specified path was deselected. The collection view calls this method when the user successfully deselects an item in the collection view. It does not call this method when you programmatically deselect items.

size​OfDecoration​View(index​Path:​)

public func sizeOfDecorationView(indexPath: IndexPath) -> CGRect  

cell​Status​For​Date(at:​column:​)

public func cellStatusForDate(at row: Int, column: Int) -> CellState?  

Returns the cellStatus of a date that is visible on the screen. If the row and column for the date cannot be found, then nil is returned

  • Paramater row: Int row of the date to find

  • Paramater column: Int column of the date to find

Returns

  • CellState: The state of the found cell

cell​Status(for:​)

public func cellStatus(for date: Date) -> CellState?  

Returns the cell status for a given date

Parameters

Parameter

date Date of the cell you want to find

Returns

  • CellState: The state of the found cell

cell​Status(for:​completion​Handler:​)

public func cellStatus(for date: Date, completionHandler: @escaping (_ cellStatus: CellState?) ->())  

Returns the cell status for a given date

Parameters

Parameter

date Date of the cell you want to find

Returns

  • CellState: The state of the found cell

month​Status(for:​)

public func monthStatus(for date: Date) -> Month?  

Returns the month status for a given date

Parameters

Parameter

date Date of the cell you want to find

Returns

  • Month: The state of the found month

cell​Status(at:​)

public func cellStatus(at point: CGPoint) -> CellState?  

Returns the cell status for a given point

Parameters

Parameter

point of the cell you want to find

Returns

  • CellState: The state of the found cell

deselect​All​Dates(trigger​Selection​Delegate:​)

public func deselectAllDates(triggerSelectionDelegate: Bool = true)  

Deselect all selected dates

Parameters

Parameter

this funciton triggers a delegate call by default. Set this to false if you do not want this

keep​Deselection​IfMulti​Selection​Allowed

if (in range selection) there are 4 dates. -> selected, unselected, selected, selected. (S | U | S | S) Deselecting those 4 dates again would give U | S | U | U. With KeepDeselection, this becomes U | U | U | U

deselect(dates:​trigger​Selection​Delegate:​keep​Deselection​IfMulti​Selection​Allowed:​)

public func deselect(dates: [Date], triggerSelectionDelegate: Bool = true, keepDeselectionIfMultiSelectionAllowed: Bool = false)  

Deselect dates

Parameters

Parameter

Dates - The dates to deselect

Parameter

triggerSelectionDelegate - this funciton triggers a delegate call by default. Set this to false if you do not want this

keep​Deselection​IfMulti​Selection​Allowed Bool

if (in range selection) there are 4 dates. -> selected, unselected, selected, selected. (S | U | S | S) Deselecting those 4 dates again would give U | S | U | U. With KeepDeselection, this becomes U | U | U | U

view​Will​Transition(to:​with:​anchor​Date:​)

public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator, anchorDate: Date?)  

Notifies the container that the size of its view is about to change.

generate​Date​Range(from:​to:​)

public func generateDateRange(from startDate: Date, to endDate: Date) -> [Date]  

Generates a range of dates from from a startDate to an endDate you provide Parameter startDate: Start date to generate dates from Parameter endDate: End date to generate dates to returns: - An array of the successfully generated dates

register(_:​for​Supplementary​View​OfKind:​with​Reuse​Identifier:​)

open override func register(_ viewClass: AnyClass?, forSupplementaryViewOfKind elementKind: String, withReuseIdentifier identifier: String)  

Registers a class for use in creating supplementary views for the collection view. For now, the calendar only supports: 'UICollectionElementKindSectionHeader' for the forSupplementaryViewOfKind(parameter)

register(_:​for​Supplementary​View​OfKind:​with​Reuse​Identifier:​)

open override func register(_ nib: UINib?, forSupplementaryViewOfKind kind: String, withReuseIdentifier identifier: String)  

Registers a class for use in creating supplementary views for the collection view. For now, the calendar only supports: 'UICollectionElementKindSectionHeader' for the forSupplementaryViewOfKind(parameter)

dequeue​Reusable​JTApple​Supplementary​View(with​Reuse​Identifier:​for:​)

public func dequeueReusableJTAppleSupplementaryView(withReuseIdentifier identifier: String, for indexPath: IndexPath) -> JTACMonthReusableView  

Dequeues re-usable calendar cells

register​Decoration​View(nib:​)

public func registerDecorationView(nib: UINib?)  

Registers a nib for use in creating Decoration views for the collection view.

register(view​Class:​for​Decoration​View​OfKind:​)

public func register(viewClass className: AnyClass?, forDecorationViewOfKind kind: String)  

Registers a class for use in creating Decoration views for the collection view.

dequeue​Reusable​JTApple​Cell(with​Reuse​Identifier:​for:​)

public func dequeueReusableJTAppleCell(withReuseIdentifier identifier: String, for indexPath: IndexPath) -> JTACDayCell  

Dequeues a reuable calendar cell

reload​Data(with​Anchor:​completion​Handler:​)

public func reloadData(withAnchor date: Date? = nil, completionHandler: (() -> Void)? = nil)  

Reloads the data on the calendar view. Scroll delegates are not

Parameters

date Date?

An anchordate that the calendar will scroll to after reload completes

animation

Scroll is animated if this is set to true

completion​Handler (() -> Void)?

This closure will run after the reload is complete

reload​Dates(_:​)

public func reloadDates(_ dates: [Date])  

Reload the date of specified date-cells on the calendar-view

Parameters

dates [Date]

Date-cells with these specified dates will be reloaded

select​Dates(from:​to:​trigger​Selection​Delegate:​keep​Selection​IfMulti​Selection​Allowed:​)

public func selectDates(from startDate: Date, to endDate: Date, triggerSelectionDelegate: Bool = true, keepSelectionIfMultiSelectionAllowed: Bool = false)  

Select a date-cell range

Parameters

start​Date Date

Date to start the selection from

end​Date Date

Date to end the selection from

trigger​Did​Select​Delegate

Triggers the delegate function only if the value is set to true. Sometimes it is necessary to setup some dates without triggereing the delegate e.g. For instance, when youre initally setting up data in your viewDidLoad

keep​Selection​IfMulti​Selection​Allowed Bool

This is only applicable in allowedMultiSelection = true. This overrides the default toggle behavior of selection. If true, selected cells will remain selected.

deselect​Dates(from:​to:​trigger​Selection​Delegate:​keep​Deselection​IfMulti​Selection​Allowed:​)

public func deselectDates(from start: Date, to end: Date? = nil, triggerSelectionDelegate: Bool = true, keepDeselectionIfMultiSelectionAllowed: Bool = false)  

Deselect all selected dates within a range

Parameters

Parameter

start - Start of date range to deselect

Parameter

end of date range to deselect

keep​Deselection​IfMulti​Selection​Allowed Bool

if (in range selection) there are 4 dates. -> selected, unselected, selected, selected. (S | U | S | S) Deselecting those 4 dates again would give U | S | U | U. With KeepDeselection, this becomes U | U | U | U

select​Dates(_:​trigger​Selection​Delegate:​keep​Selection​IfMulti​Selection​Allowed:​)

public func selectDates(_ dates: [Date], triggerSelectionDelegate: Bool = true, keepSelectionIfMultiSelectionAllowed: Bool = false)  

Select a date-cells

Parameters

date

The date-cell with this date will be selected

trigger​Did​Select​Delegate

Triggers the delegate function only if the value is set to true. Sometimes it is necessary to setup some dates without triggereing the delegate e.g. For instance, when youre initally setting up data in your viewDidLoad

keep​Selection​IfMulti​Selection​Allowed Bool

if (in range selection) there are 4 dates. -> selected, unselected, selected, selected. (S | U | S | S) Selecting those 4 dates again would give U | S | U | U. With KeepSelection, this becomes S | S | S | S

scroll​ToSegment(_:​trigger​Scroll​ToDate​Delegate:​animate​Scroll:​extra​Added​Offset:​completion​Handler:​)

public func scrollToSegment(_ destination: SegmentDestination,
                                triggerScrollToDateDelegate: Bool = true,
                                animateScroll: Bool = true,
                                extraAddedOffset: CGFloat = 0,
                                completionHandler: (() -> Void)? = nil)  

Scrolls the calendar view to the next section view. It will execute a completion handler at the end of scroll animation if provided.

  • Paramater direction: Indicates a direction to scroll

  • Paramater animateScroll: Bool indicating if animation should be enabled

Parameters

trigger​Scroll​ToDate​Delegate Bool

trigger delegate if set to true

completion​Handler (() -> Void)?

A completion handler that will be executed at the end of the scroll animation

scroll​ToDate(_:​trigger​Scroll​ToDate​Delegate:​animate​Scroll:​preferred​Scroll​Position:​extra​Added​Offset:​completion​Handler:​)

public func scrollToDate(_ date: Date,
                             triggerScrollToDateDelegate: Bool = true,
                             animateScroll: Bool = true,
                             preferredScrollPosition: UICollectionView.ScrollPosition? = nil,
                             extraAddedOffset: CGFloat = 0,
                             completionHandler: (() -> Void)? = nil)  

Scrolls the calendar view to the start of a section view containing a specified date.

  • Paramater date: The calendar view will scroll to a date-cell containing this date if it exists

  • Paramater animateScroll: Bool indicating if animation should be enabled

  • Paramater preferredScrollPositionIndex: Integer indicating the end scroll position on the screen. This value indicates column number for Horizontal scrolling and row number for a vertical scrolling calendar

Parameters

trigger​Scroll​ToDate​Delegate Bool

Trigger delegate if set to true

completion​Handler (() -> Void)?

A completion handler that will be executed at the end of the scroll animation

scroll​ToHeader​For​Date(_:​trigger​Scroll​ToDate​Delegate:​with​Animation:​extra​Added​Offset:​completion​Handler:​)

public func scrollToHeaderForDate(_ date: Date,
                                      triggerScrollToDateDelegate: Bool = false,
                                      withAnimation animation: Bool = false,
                                      extraAddedOffset: CGFloat = 0,
                                      completionHandler: (() -> Void)? = nil)  

Scrolls the calendar view to the start of a section view header. If the calendar has no headers registered, then this function does nothing

  • Paramater date: The calendar view will scroll to the header of a this provided date

visible​Dates()

public func visibleDates()-> DateSegmentInfo  

Returns the visible dates of the calendar.

Returns

  • DateSegmentInfo

visible​Dates(_:​)

public func visibleDates(_ completionHandler: @escaping (_ dateSegmentInfo: DateSegmentInfo) ->())  

Returns the visible dates of the calendar.

Returns

  • DateSegmentInfo

current​Section()

public func currentSection() -> Int?  

Retrieves the current section

layout​Subviews()

override open func layoutSubviews()  

Lays out subviews.

reload​Data()

@available(*, unavailable)
    open override func reloadData()  

scroll​View​Did​Scroll​ToTop(_:​)

public func scrollViewDidScrollToTop(_ scrollView: UIScrollView)  

Inform the scrollViewDidEndDecelerating function that scrolling just occurred

scroll​View​Will​End​Dragging(_:​with​Velocity:​target​Content​Offset:​)

open func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)  

Tells the delegate when the user finishes scrolling the content.

scroll​View​Did​End​Dragging(_:​will​Decelerate:​)

public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)  

scroll​View​Did​End​Scrolling​Animation(_:​)

public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView)  

Tells the delegate when a scrolling animation in the scroll view concludes.

scroll​View​Did​End​Decelerating(_:​)

open func scrollViewDidEndDecelerating(_ scrollView: UIScrollView)  

Tells the delegate that the scroll view has ended decelerating the scrolling movement.

scroll​View​Did​Scroll(_:​)

public func scrollViewDidScroll(_ scrollView: UIScrollView)  

Tells the delegate that a scroll occurred