Skip to content

The final Apple calendar you will ever try. Built for iOS in Swift.

License

Notifications You must be signed in to change notification settings

krisanthony/JTAppleCalendar

 
 

Repository files navigation

JTAppleCalendar

The final iOS calendar control you'll ever try

Inspiration for this control was made possible by Michael @ Karmadust. Want to know how the calendar control works inside out? Check out his KDCalendar tutorial.

CI Status Version License Platform

About Screenshots

Much like a UITableView, because you can design this calendar to look however you want, screenshots will not be an accurate depiction of what this control looks like, but you can check out what people have developed with this control and also post you own images at this link.. A sample iOS application is also included in this project's Github Repository to give you an idea of what you can do.

  • Downloaded and liked this calendar's ease of use?
  • Then don't forget to leave a ★ Star rating on Github. It's needed to make this control #1 :)
  • Also, Support is not manditory, but will be much appreciated.

Features


  • Boundary dates - limit the calendar date range
  • Week/month mode - show 1 row of weekdays. Or 2, 3 or 6
  • Custom cells - make your day-cells look however you want, with any functionality you want
  • Custom calendar view - make your calendar look however you want, with what ever functionality you want
  • First Day of week - pick anyday to be first day of the week
  • Horizontal or vertical mode
  • Ability to add month headers in varying sizes/styles of your liking
  • Ability to scroll to any month by simply using the date
  • Ability to design your calendar however you want. You want it, you build it
  • Complete Documentation

Requirements


  • iOS 8.0+
  • Xcode 7.2+

Communication on Github


Installation using CocoaPods

CocoaPods is a dependency manager for Cocoa projects. Cocoapods can be installed with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build JTAppleCalendar

To integrate JTAppleCalendar into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'JTAppleCalendar'

Then, run the following command at your project location:

$ pod install

The Problem


  1. Apple has no calendar control.
  2. Other calendar projects on Github try to cram every feature into their control, hoping it will meet the programmer's requirements.

This is an incorrect way to build controls. It leaves the developer with an extremely wide selection of (in many cases non-conventional) features that he has to sift through in order to configure the calendar. Also, no matter how wide the feature selection, the developer is always restricted to a predefined configuration-set shipped with the calendarControl. Do you see Apple building their UITableView by guessing what they think you want the UITableView to look like? No. So neither should we.

The Solution: JTAppleCalendar


Properties/functions/structs to help configure your calendar

The following structure was returned when a cell is about to be displayed.

    public enum DateOwner: Int {
        case ThisMonth = 0, PreviousMonthWithinBoundary, PreviousMonthOutsideBoundary, FollowingMonthWithinBoundary, FollowingMonthOutsideBoundary
    }
  • .ThisMonth = the date to be displayed belongs to the month section
  • .PreviousMonthWithinBoundary = date belongs to the previous month, and it is within the date boundary you set
  • .PreviousMonthOutsideBoundary = date belongs to previous month, and it is outside the boundary you have set
  • .FollowingMonthWithinBoundary = date belongs to following month, within boundary
  • .FollowingMonthOutsideBoundary = date belongs to following month, outside boundary
    public func changeNumberOfRowsPerMonthTo(number: Int, withFocusDate date: NSDate?) // After switching the number of rows shown, pick a date to autofocus on
    public func reloadData()
    public func scrollToNextSegment(animateScroll: Bool = true, completionHandler:(()->Void)? = nil) 
    public func scrollToPreviousSegment(animateScroll: Bool = true, completionHandler:(()->Void)? = nil)
    public func scrollToDate(date: NSDate, animateScroll: Bool = true, completionHandler:(()->Void)? = nil)
    public func selectDates(dates: [NSDate], triggerSelectionDelegate: Bool = true)
    public func cellStatusForDateAtRow(row: Int, column: Int) -> CellState?

Properties you can configure

// Note: You do not need to configure your calendar with this if it is already the default
calendarView.direction = .Horizontal                       // default is horizontal
calendarView.numberOfRowsPerMonth = 6                      // default is 6
calendarView.cellInset = CGPoint(x: 0, y: 0)               // default is (3,3)
calendarView.allowsMultipleSelection = false               // default is false
calendarView.bufferTop = 0                                 // default is 0. - still work in progress
calendarView.bufferBottom = 0                              // default is 0. - still work in progress
calendarView.firstDayOfWeek = .Sunday                      // default is Sunday
calendarView.scrollEnabled = true                          // default is true
calendarView.pagingEnabled = true                          // default is true
calendarView.scrollResistance = 0.75                       // default is 0.75 - this is only applicable when paging is not enabled

Do you have any other questions?. If you are trying to bend heaven and earth to do something complicated with this calendar, then chances are there is already an easy way for it to be done. So Opening an issue might be a good idea.

Did you remember to leave a like? I would really appreciate it if you did.

Other functions/properties are coming. This is a very active project.

Author

JayT, patchthecode@gmail.com

License

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

About

The final Apple calendar you will ever try. Built for iOS in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 85.5%
  • Shell 12.3%
  • Ruby 1.5%
  • Objective-C 0.7%