Koyomi
Koyomi is a simple calendar view framework for iOS, written in Swift.
Features
- Simple Calendar View :calendar:
- Easily usable :sunglasses:
- Customizable in any properties for appearance
- Selectable calender
- Complete
README
- [x] Support
@IBDesignable
and@IBInspectable
- [x] Compatible with Carthage
- [x] Support Swift 2.3.
- [x] Support Swift 3.0
Demo App
Open Example/Koyomi.xcworkspace
and run Koyomi-Example
to see a simple demonstration.
Usage
Koyomi is designed to be easy to use :sunglasses:
Koyomi
is available in Interface Builder.
Set custom class of UICollectionView
to Koyomi
:calendar: Change displayed month
If you want to change displayed month, call display(in: MonthType)
. MonthType
is defined by three types.
Hide days of other months
If you want to hide days of other months, set isHiddenOtherMonth
to true
.
Days of other months aren't displayed and user can't select.
Get current month string
NOTE
If you want to change
dateFormat
ofcurrentDateString
, set argument to format.currentDateString(withFormat: "MM/yyyy")
default
dateFormat
ofcurrentDateString
isM/yyyy
The selection state of date
You can configure SelectionMode with style.
SelectionMode has nested enumerations type: SequenceStyle
, Style
.
single | ![]() |
![]() |
![]() |
---|---|---|---|
SelectionMode | .single(style: .background) |
.single(style: .circle) |
.single(style: .line) |
multiple | ![]() |
![]() |
![]() |
---|---|---|---|
SelectionMode | .multiple(style: .background) |
.multiple(style: .circle) |
.multiple(style: .line) |
sequence | ![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
SelectionMode | .sequence(style: .background) |
.sequence(style: .circle) |
.sequence(style: .semicircleEdge) |
.sequence(style: .line) |
You can configure lineView in the case of line
style.
NOTE
If you don't want to allow user to select date by user interaction, set
selectionMode
to.none
.
Select date in programmatically
You can select specific date .
You can also unselect available.
You can configure style color and text state in selected state.
selectedDayTextState
If you want to change day textColor when the user selects day in the Koyomi
, set selectedDayTextState
to SelectedTextState.change(UIColor)
.
Also, if you don't want to change day textColor when the user selects day, set selectedDayTextState
to SelectedTextState.keeping
.
Highlight specific days
You can change dayColor
and dayBackgroundColor
in specific days.
KoyomiDelegate
If you want to use KoyomiDelegate
, set calendarDelegate
to target
Declaration
koyomi(_: didSelect: forItemAt)
Tells the delegate that the date at the specified index path was selected.
date
: the date user selected, when tapped cell
koyomi(_: currentDateString:)
Tells the delegate that the displayed month is changed.
currentDateString
: the current month string, when changed month.
koyomi(_: shouldSelectDates: to: withPeriodLength)
koyomi
calls this method before select days.
return value: true if the item should be selected or false if it should not. to
is always nil if selectionMode
isn't sequence
.
koyomi(_: selectionColorForItemAt: date:)
koyomi
calls this method before setting selectionColor for specific date.
return value: UIColor instance for a different color then the default one or return nil to use the default color.
koyomi(_: fontForItemAt: date:)
koyomi
calls this method before setting font for specific date.
return value: UIFont instance for a different font then the default one or return nil to use the default font.
:wrench: Customize Koyomi
Customize layout properties
Set sectionSpace
, cellSpace
, weekCellHeight
in initialization or Interface Builder.
Customize text postion
You can configure text postion.
Customize text font
Customize weeks text
Customize color properties
You can configure the lots of color properties for appearance :weary:
Don't worry :stuck_out_tongue_closed_eyes:, you can easily configure appearance by using KoyomiStyle
.
KoyomiStyle
is defined by 19 types + 1 custom.
used iOS Human Interface Guidelines as reference
To use a custom color scheme, you need to define tuple with the necessarry values
Requirements
- iOS 8.0+
- Xcode 8.0+
- Swift 3.0+
Installation
Installation of Swift 2.3
Please install version 0.1.6
or earlier.
pod 'Koyomi', '~> 0.1.6'
CocoaPods
Koyomi is available through CocoaPods.
To install it, simply add the following line to your Podfile
:
Carthage
Add the following line to your Cartfile
:
App using Koyomi
If you're using Koyomi in your app, please open a PR to add it to this list! :blush:
Author
shoheiyokoyama, shohei.yok0602@gmail.com