项目作者: matsune

项目描述 :
Monthly event calendar framework for iOS
高级语言: Swift
项目地址: git://github.com/matsune/YMCalendar.git
创建时间: 2017-03-26T03:58:44Z
项目社区:https://github.com/matsune/YMCalendar

开源协议:MIT License

下载


" class="reference-link">Logo

Build Status
Language
Platform
Carthage compatible
Cocoapods
License

YMCalendar

YMCalendar is a library of monthly event calendar for iOS written in Swift.

Screenshots

creen

GIF



Usage

Property" class="reference-link"> Property

YMCalendarView has some instance properties like UICollectionView.

  • Scrollable both vertically and horizontally
  • Switching paging mode
  • Multiple selection mode
  1. var scrollDirection: YMScrollDirection
  2. var isPagingEnabled: Bool
  3. var allowsMultipleSelection: Bool
  • Customizable select and deselect animation.
  1. enum YMSelectAnimation {
  2. case none, bounce, fade
  3. }
  4. var selectAnimation: YMSelectAnimation
  5. var deselectAnimation: YMSelectAnimation
  • Customizable date range of calendarView.
    1. func setDateRange(_ dateRange: DateRange?)
    If you set nil for dateRange, it will be inifinite scroll calendar (default is nil).

Layout customization" class="reference-link"> Layout customization

Appearance protocol" class="reference-link"> Appearance protocol

YMCalendarView has appearance property of YMCalendarAppearance protocol which manages layout for YMCalendarView.
For example, color and width of grid lines, color and fonts of day labels on calendarView.

  1. func horizontalGridColor(in view: YMCalendarView) -> UIColor
  2. func horizontalGridWidth(in view: YMCalendarView) -> CGFloat
  3. func verticalGridColor(in view: YMCalendarView) -> UIColor
  4. func verticalGridWidth(in view: YMCalendarView) -> CGFloat
  5. func dayLabelAlignment(in view: YMCalendarView) -> YMDayLabelAlignment
  6. func calendarViewAppearance(_ view: YMCalendarView, dayLabelFontAtDate date: Date) -> UIFont
  7. func calendarViewAppearance(_ view: YMCalendarView, dayLabelTextColorAtDate date: Date) -> UIColor
  8. func calendarViewAppearance(_ view: YMCalendarView, dayLabelBackgroundColorAtDate date: Date) -> UIColor
  9. func calendarViewAppearance(_ view: YMCalendarView, dayLabelSelectedTextColorAtDate date: Date) -> UIColor
  10. func calendarViewAppearance(_ view: YMCalendarView, dayLabelSelectedBackgroundColorAtDate date: Date) -> UIColor

Gradient background" class="reference-link"> Gradient background

You can set gradient colors for background of YMCalendarView.

  1. var gradientColors: [UIColor]?
  2. var gradientLocations: [NSNumber]?
  3. var gradientStartPoint: CGPoint
  4. var gradientEndPoint: CGPoint

Delegate" class="reference-link"> Delegate

YMCalendarDelegate protocol methods will be called by your scrolling and selection actions.
The methods of this protocol are all optional.

  1. func calendarViewDidScroll(_ view: YMCalendarView)
  2. func calendarView(_ view: YMCalendarView, didSelectDayCellAtDate date: Date)
  3. func calendarView(_ view: YMCalendarView, didMoveMonthOfStartDate date: Date)
  4. func calendarView(_ view: YMCalendarView, shouldSelectEventAtIndex index: Int, date: Date) -> Bool
  5. func calendarView(_ view: YMCalendarView, didSelectEventAtIndex index: Int, date: Date)
  6. func calendarView(_ view: YMCalendarView, shouldDeselectEventAtIndex index: Int, date: Date) -> Bool
  7. func calendarView(_ view: YMCalendarView, didDeselectEventAtIndex index: Int, date: Date)

DataSource" class="reference-link"> DataSource

An object that abopts YMCalendarDataSource protocol is responsible for provising the data and views about events of days.

  1. func calendarView(_ view: YMCalendarView, numberOfEventsAtDate date: Date) -> Int
  2. func calendarView(_ view: YMCalendarView, dateRangeForEventAtIndex index: Int, date: Date) -> DateRange?
  3. func calendarView(_ view: YMCalendarView, eventViewForEventAtIndex index: Int, date: Date) -> YMEventView

If you want to create original eventView, it should inherit YMEventView. You can dequeue the original eventView by registering to calendarView with identifier (Please see demo project).

EKEvent" class="reference-link"> EKEvent

If you want to use EventKit as a data source, create an instance of YMCalendarEKViewController. This superclass has calendarView and system of loading EKEvents. Please see EKEventKitViewController in demo project.

Installation

Carthage

  1. github "matsune/YMCalendar"

CocoaPods

  1. pod "YMCalendar"

Author

Yuma Matsune

License

YMCalendar is available under the MIT license. See the LICENSE file for more info.