πŸ“… Calendar for iOS, iPadOS and macOS in Swift

Overview

CalendarKit License SwiftPM compatible Swift Compatibility Platform Compatibility Tag Version

CalendarKit

CalendarKit is a Swift calendar UI library for iOS, iPadOS and Mac Catalyst. It looks similar to the Apple Calendar app out-of-the-box, while allowing customization when needed. CalendarKit is composed of multiple modules which can be used together or independently.

Tutorials

Create iOS Calendar App in Swift with CalendarKit

Need Help?

If you have a programming question about how to use CalendarKit in your application, ask it on StackOverflow with the CalendarKit tag. Check out the Sample App for reference.

Please, use GitHub Issues only for reporting a bug or requesting a new feature.

Examples

Video

Sample App

Try live in a browser

To try CalendarKit with CocoaPods issue the following command in the Terminal:

pod try CalendarKit

Installation

CalendarKit can be installed with Swift Package Manager or with CocoaPods.

Swift Package Manager (Xcode 12 or higher)

The preferred way of installing CalendarKit is via the Swift Package Manager.

  1. In Xcode, open your project and navigate to File β†’ Swift Packages β†’ Add Package Dependency...
  2. Paste the repository URL (https://github.com/richardtop/CalendarKit.git) and click Next.
  3. For Rules, select Version (Up to Next Major) and click Next.
  4. Click Finish.

Adding Package Dependencies to Your App

CocoaPods

To install it, add the following line to your Podfile:

pod 'CalendarKit'

Adding Pods to an Xcode project

Usage

  1. Subclass DayViewController
  2. Implement EventDataSource protocol to show events.

CalendarKit requires EventDataSource to return an array of objects conforming to EventDescriptor protocol, specifying all the information needed to display a particular event. You're free to use a default Event class as a model or create your own class conforming to the EventDescriptor protocol.

// Return an array of EventDescriptors for particular date
override func eventsForDate(_ date: Date) -> [EventDescriptor] {
  var models = myAppEventStore.getEventsForDate(date) // Get events (models) from the storage / API

  var events = [Event]()

  for model in models {
      // Create new EventView
      let event = Event()
      // Specify StartDate and EndDate
      event.startDate = model.startDate
      event.endDate = model.endDate
      // Add info: event title, subtitle, location to the array of Strings
      var info = [model.title, model.location]
      info.append("\(datePeriod.beginning!.format(with: "HH:mm")) - \(datePeriod.end!.format(with: "HH:mm"))")
      // Set "text" value of event by formatting all the information needed for display
      event.text = info.reduce("", {$0 + $1 + "\n"})
      events.append(event)
  }
  return events
}

After receiving an array of events for a particular day, CalendarKit will handle view layout and display.

Usage

To respond to the user input, override mehtods of DayViewDelegate, for example:

override func dayViewDidSelectEventView(_ eventView: EventView) {
  print("Event has been selected: \(eventview.data)")
}

override func dayViewDidLongPressEventView(_ eventView: EventView) {
  print("Event has been longPressed: \(eventView.data)")
}

Localization

CalendarKit supports localization and uses iOS default locale to display month and day names. First day of the week is also selected according to the iOS locale.

GermanNorwegian

Styles

By default, CalendarKit looks similar to the Apple Calendar app and fully supports Dark Mode. If needed, CalendarKit's look can be easily customized. Steps to apply a custom style are as follows:

  1. Create a new CalendarStyle object (or copy existing one)
  2. Change style by updating the properties.
  3. Invoke updateStyle method with the new CalendarStyle.
let style = CalendarStyle()
style.backgroundColor = UIColor.black
dayView.updateStyle(style)

Light theme Dark theme

Requirements

  • iOS 9.0+, iPadOS 13.0+, macOS 10.15+
  • Swift 4+ (Library is written in Swift 5.3)

Contributing

The list of features currently in development can be viewed on the issues page.

Before contributing, please review guidelines and code style.

Author

Richard Topchii

License

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

Comments
  • Open on a date weeks in the future

    Open on a date weeks in the future

    It's 13 May but I want to show the dayView for 23 September.

    I've tried calling changeCurrentDate(to newDate: Date). My chosen date is displayed briefly and then display switches to 20 May.

    Is there a way to start at a date other than today?

    bug 
    opened by keith-nativemobile 22
  • I just need Timeline view not with the calendar. Is there any possibilities?

    I just need Timeline view not with the calendar. Is there any possibilities?

    New Issue Checklist

    Issue Description

    Code I'm using with CalendarKit
    
    [INSERT CODE HERE]
    
    

    Result I am trying to achieve

    [INSERT API OR UI MOCKUPS HERE]

    question 
    opened by SunnyBamaniya 20
  • Fails to build when accessed via notification content extension

    Fails to build when accessed via notification content extension

    New Issue Checklist

    Issue Description

    I'm using a new SwiftUI app to update my existing project. The only place I use CalendarKit is in the notification content extension, which is still UIKit. I added your library via SPM and made sure to point at the master branch. I'm using the exact same code as the original version used. The only difference is that one was done via CocoaPods and this one is of course using Swift Package Manager.

    As soon as I use something like TimelineView I'm getting tons of errors.

    Code I'm using with CalendarKit
    let timeline = TimelineView()
    

    That line, for example, will result in these errors:

    Undefined symbol: type metadata accessor for CalendarKit.TimelineView Undefined symbol: CalendarKit.TimelineView.__allocating_init() -> CalendarKit.TimelineView

    NotificationViewController.txt

    bug 
    opened by grosch 15
  • CocoaPods downloads old version of the library

    CocoaPods downloads old version of the library

    I'm a beginner in Swift and this is the first time I'm using a library so I'm sorry if this is a stupid question. I installed CalendarKit into my Xcode project and I had a few errors from the compiler. Although I can fix most of them, there are 2 that I don't know how to get rid of. Could someone please help and see how I could remove these errors? Thank you so much!

    screen shot 2017-10-25 at 4 21 25 pm screen shot 2017-10-25 at 4 21 14 pm bug 
    opened by pacowong99 13
  • Layout Issue when using UISplitViewController

    Layout Issue when using UISplitViewController

    Hi, as i descriped on stackoverflow, i can't using CalendarKit inside UISplitViewController When i set the CalendarViewController as primary viewcontroller, the result looks like this:

    Bildschirmfoto 2021-10-03 um 14 47 52

    As you can see, the CalendarViewController fits the iPhone Screen, but not the primary column on the iPad (SplitView). How can i solve this issue?

    I am using the CalendarKitApp Template and modified the SceneDelegate like this:

    var splitView: UISplitViewController?
    
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        self.makeSplitViewController()
        
        if let windowScene = scene as? UIWindowScene {
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = self.splitView
            self.window = window
            window.makeKeyAndVisible()
    
            self.splitView?.viewController(for: .secondary)?.navigationController?.navigationBar.barStyle = .black
        }
    }
    
    func makeSplitViewController() {
        let splitViewController = UISplitViewController(style: .doubleColumn)
        splitViewController.preferredDisplayMode = .oneBesideSecondary
        
        let primaryViewController = UINavigationController(rootViewController: CalendarViewController())
        let secondaryViewController = UIHostingController(rootView: EventDetailView()) // -> SwiftUI View
        
        splitViewController.setViewController(primaryViewController, for: .primary)
        splitViewController.setViewController(secondaryViewController, for: .secondary)
        splitViewController.setViewController(primaryViewController, for: .compact)
        
        self.splitView = splitViewController
    }
    
    bug 
    opened by niklasgrewe 11
  • currentTimeIndicator

    currentTimeIndicator

    I am using this library as child to my accordance but the time indicator show the correct time but the place where it shows, is wrong? can you please help me out to get over from this issue.

    bug 
    opened by akki147 11
  • Allow BYO header view, ability to set current date, maintain date order after a jump, long press timeline delegate callback

    Allow BYO header view, ability to set current date, maintain date order after a jump, long press timeline delegate callback

    1. BYO header view
    • Allow hiding the built-in header view so that users can use their own header views
    1. Ability to set current date
    • Expose function to set the current date in DayView
    1. Maintain date order after a jump
    • When jumping dates (by tapping on date in header view instead of swiping), the next swipe back jumps back to the previous date before the jump, instead of the previous date in the calendar. This fixes that issue.
    1. Long press in timeline view delegate callback
    • Add delegate callback when the timeline view is long pressed in an area without any events
    opened by v-ken 11
  • New Year - Off by one error for the first week.

    New Year - Off by one error for the first week.

    New Issue Checklist

    Issue Description

    At the start of the year, Week 1 appears to show the dates for a year +1 in the future. e.g. as we've just entered 2018, the calendar is showing the dates for 2019 for week one

    Note that 4th Jan 2018 is a Thursday, but here it is displayed as a Friday.

    screen shot 2018-01-04 at 08 58 17

    bug 
    opened by jameswwwebster 10
  • View for notification

    View for notification

    This looks like an awesome library. Is there a way to customize the view so it just shows the time around a specific timeframe? I'd like to use this in a custom UI for a rich push notification but obviously I don't want to show the whole day, just a couple hours before and after the event that's pushed to the user.

    question 
    opened by grosch 10
  • Italian localization

    Italian localization

    New Issue Checklist

    Issue Description

    Missing Italian localization, it's possibile to add?

    bug enhancement 
    opened by spiccinocchi 9
  • EventView - Edit TextView Frame?

    EventView - Edit TextView Frame?

    Hey all,

    I'm looking for what I hope is a simple fix. I'd like to remove the top padding of the event view, so that the TextView aligns more towards the top of the EventView, and not in the center as it does now.

    Can anyone point me in the right direction?

    bug enhancement 
    opened by payshake 8
  • "isHeaderViewVisible" only hide the subview without resizing the timelinePageViewer

    New Issue Checklist

    Issue Description

    After to set the property to false, this sentence only hide the dayHeaderView view leaving a white space (The green background is just for reference)

    myView.isHeaderViewVisible = false
    
    Screen Shot 2022-06-07 at 17 30 45

    Result I am trying to achieve

    The possible fix that needs a change in the library.

    I did a small change on the file DayView (inside CalendarKit) project removing the else

    
    // Before
    override public func layoutSubviews() {
        super.layoutSubviews()
        if #available(iOS 11, *) {} else {
            ...
        }
      }
    
    // After
    override public func layoutSubviews() {
        super.layoutSubviews()
        if #available(iOS 11, *) { // Removing the else case
            ...
        }
      }
    
    

    and the frame is recalculated.

    Screen Shot 2022-06-07 at 17 36 49

    Final Note

    To be sure that I'm not doing something wrong in my project I did the same change trying with the CalendarKitDemo project inside this repository and the bug is present.

    Screen Shot 2022-06-07 at 18 14 58

    bug 
    opened by Jhegs 1
  • How can I get specific eventView without any gesture?

    How can I get specific eventView without any gesture?

    Hi,

    I'd like to know is there anyway to get specific eventview without any gesture such as tap or longpress?

    The scerino will be I get a data from server, then i want to find the event match the data, and show a popover with the eventview's source rect. So the whole workaround will not have any user interaction.

    enhancement 
    opened by qubyedev 7
  • External drag end drop

    External drag end drop

    Hi, Is there a possibility to drag n drop an event from external table to the calendar? Note that I mean external table next to the calendar in the same app not in another app. Thanks Pampos

    enhancement 
    opened by Pamposgsk 1
  • Problem with UIPageviewController with moveTo

    Problem with UIPageviewController with moveTo

    New Issue Checklist

    Issue Description

    Hi Richard,

    I have a problem once I changed to iOS15, I waited till the iOS15 RC to write this issue. The problem is that changing days using 'moveTo' or using the header, at the end everything gets messy, half pages, not doing apparently the layout or some other things you can see on the video attached.

    I tried removing all my code that modifies the creation of the Event with no success. I've seen that inside the func move in TimelinePagerView that (pagingViewController.setViewControllers) you implemented some kind of workaround, but seems not to work right now. I did also some research in stackoverflow with little success.

    Do you have any advice on this?

    Thanks a lot. Alex.

    https://user-images.githubusercontent.com/32038447/133603473-7fc05a0f-2c9d-4612-bbce-81d8eadd9dba.mov

    bug 
    opened by IronMaltes 4
  • Month View

    Month View

    I needed a native-looking calendar to display both day views and month views. Calendar kit is perfect for day view but doesn't have an option to display the month view so I've created one. The regular DayViewController works as it did before. There is now a MonthViewController as well that does the same things but displays a month calendar view at the top instead of the bar of the days in the week. There is also a hybrid DayOrMonthViewController that can toggle seamlessly between the two headers when the function toggleDayMonthButtonTapped() is called.

    opened by AdoptedChildOfGod 5
Releases(1.1.0)
Owner
Richard Topchii
Richard Topchii
πŸ“… Calendar for iOS, iPadOS and macOS in Swift

CalendarKit CalendarKit is a Swift calendar UI library for iOS, iPadOS and Mac Catalyst. It looks similar to the Apple Calendar app out-of-the-box, wh

Richard Topchii 2.2k Jan 5, 2023
Malendar is a personal calendar app that connects to your default calendar and lets you add/delete events

Malendar is a personal calendar app that connects to your default calendar and lets you add/delete events. It will gather events from your default iOS calendar.

Chase 194 Jan 4, 2023
A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

HorizonCalendar A declarative, performant, calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-feat

Airbnb 2.2k Jan 4, 2023
Simple customizable calendar component in Swift :calendar:

Koyomi Koyomi is a simple calendar view framework for iOS, written in Swift ?? Content Features Demo App Usage introduction : Change displayed month,

Shohei Yokoyama 741 Dec 24, 2022
A library that expresses a github contribution calendar through an array of dates. Supports iOS and macOS.

A library that expresses a github contribution calendar through an array of dates. Supports iOS and macOS.

jasu 45 Dec 20, 2022
A calendar quick view for the MacOS status bar

Calendar Quick View Quick Menu Calendar in the mac app store An open source macOS calendar preview utility Download from the Mac App Store Visualizati

Michaellis 18 Oct 26, 2022
A fully customizable iOS calendar library, compatible with Objective-C and Swift

Table of contents Screenshots Installation Pre-knowledge Support Contact Screenshots iPhone iPad Safe Orientation Today Extension iOS8/9 iOS10 Interac

Wenchao Ding 10.2k Jan 2, 2023
CalendarApp Swift - Made a calendar app in swift, completely from scratch using UIStackView and UICollectionView

CalendarApp_Swift Made a calendar app in swift, completely from scratch using UI

Arnav Chhokra 1 Feb 4, 2022
Calendar View - It's lightweight and simple control with supporting Locale and CalendarIdentifier.

iOS Calendar It's lightweight and simple control with supporting Locale and CalendarIdentifier. There're samples for iPhone and iPad, and also with us

Maksym Bilan 159 Dec 22, 2022
An open source calendar framework for iOS, with support for customization, IBDesignable, Autolayout, and more.

About MBCalendarKit is a calendar control written in Objective-C with modern best practices and Swift interoperability in mind. It offers a flexible c

Moshe 563 Oct 27, 2022
An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

Joe L 420 Dec 22, 2022
An Easy to Use Calendar for iOS (Swift 5.0)

This is an easy to use, "just drag and drop it in your code" type of calendar for iOS. It supports both vertical and horizontal scrolling, as well as

Michael Michailidis 525 Dec 23, 2022
A custom visual calendar for iOS 8+ written in Swift (>= 4.0).

Overview Screenshots GIF Demo Installation Usage Architecture Version matrix Advanced API For contributors Screenshots GIF Demo Installation CocoaPods

null 3.5k Dec 24, 2022
A calendar control for iOS written in swift with mvvm pattern

ASCalendar try it on appetize Installation CocoaPods You can use CocoaPods to install ASCalendar by adding it to your Podfile: platform :ios, '8.0' us

Alberto Scampini 192 Jun 26, 2022
A SwiftUI calendar view that allows month switching and date picking.

Selectable Calendar View A SwiftUI calendar view that allows month switching and date picking. Usage You can simply add this repository to your projec

γ‚·γƒ₯ンジョーゑ 10 Jul 21, 2022
SwiftUI Simple Calendar / Date Picker for iOS

RKCalendar RKCalendar is a SwiftUI Calendar / Date Picker for iOS. Features include: minimum and maximum calendar dates selectable, single date select

null 453 Dec 28, 2022
iOS 7+ Calendar (Date Picker) with Infinite Scrolling.

RSDayFlow iOS 7 Calendar with Infinite Scrolling. Only need 4 lines of code to set up. RSDayFlow is a slim fork of DayFlow with updates and extensions

Ruslan Skorb 844 Sep 14, 2022
An availability calendar implementation for iOS

NWCalendarView NWCalendar View is an iOS control that displays a calendar. It is perfect for appointment or availibilty selection. It allows for selec

Nicholas Wargnier 60 May 27, 2021
A customizable calendar view for iOS.

JTCalendar JTCalendar is an easily customizable calendar control for iOS. Installation With CocoaPods, add this line to your Podfile. pod 'JTCalendar'

Jonathan Vukovich-Tribouharet 2.8k Dec 27, 2022