A custom visual calendar for iOS 8+ written in Swift (>= 4.0).

Overview

pod License Build Status Twitter

Overview

Screenshots

GIF Demo

Installation

CocoaPods

pod 'CVCalendar', '~> 1.7.0'

Usage

Using CVCalendar isn't difficult at all. There are two actual ways of implementing it in your project:

  • Storyboard setup
  • Manual setup

So let's get started.

Warning! Since 1.1.1 version CVCalendar requires an implementation of two protocols CVCalendarViewDelegate and CVCalendarMenuViewDelegate, please implement both. Also note, they both have a method with the same signature which means you need to impement it only once. Take a look at the Demo project for more info.

Storyboard Setup

Basic setup.

First, you have to integrate CVCalendar with your project through CocoaPods.

Now you're about to add 2 UIViews to your Storyboard as it shown in the picture below.
alt tag

Don't forget to add 2 outlets into your code.

    @IBOutlet weak var menuView: CVCalendarMenuView!
    @IBOutlet weak var calendarView: CVCalendarView!

Two views are representing ultimately a MenuView and a CalendarView so they should have corresponding classes. To change their classes go to Identity Inspector and set custom classes. When it's done, you'll see in the dock panel something similar to the picture below. (Blue UIView -> CVCalendarView, Green UIView -> CVCalendarMenuView)

alt tag

NOTE: Please note that both CalendarView and MenuView are calculating their content's frames depending on their own ones. So in your projects you may be editing the size of initial UIViews in the storyboard to reach an optimal content size.

Important note.
Before we move to setting up delegates for customization stuff, you should know that CalendarView's initialization is devided by 2 parts: * On Init. * On Layout.

As well as most of the developers are using AutoLayout feature UIView's size in the beginning of initialization does not match the one on UIView's appearing. Thus we have either to initialize ContentView with MonthViews and all the appropriate stuff on UIView's appearing or initialize stuff as UIView's being initialized and then simply update frames. The first option doesn't work since there will be a flash effect (the initialization will be finished after your UIView appeared) according to what the CVCalendar has 2 parts of creating.

Since CVCalendarView and CVCalendarMenuView will be created automatically all you have to do is this (in the ViewController that contains CVCalendar).

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()

        menuView.commitMenuViewUpdate()
        calendarView.commitCalendarViewUpdate()
    }

Delegates Setup (Customization).

CVCalendar requires to implement two protocols. They are CVCalendarViewDelegate and CVCalendarMenuViewDelegate. Note that the last one has exactly the same named method as the first one declares which means you have to implement only required methods in CVCalendarViewDelegate and set your controller as a delegate implementing both protocols.

These protocols stand for getting the data for building CVCalendarView and CVCalendarMenuView. So do not forget to implement them.

API Page

A long story in short or customizable properties:

  • Showing weekdays out
  • Moving dot markers on highlighting
  • Showing dot markers on a specific day view
  • Dot marker's color, offset and size
  • Space between week views and day views
  • Day view's label properties (color, background, alpha + different states (normal/highlighted))

Behavior:

  • Day view selection
  • Presented date update
  • Animations on (de)selecting day views

Finally we're going to customize properties. To make this possible you have to implement approptiate protocols. (You can see presented protocols and short descriptions in the Architecture Section). Open your Storyboard and do a right-click on CVCalendarView, you'll see the window with outlets and there are a few ones we actually need. Take a look at the picture to make sure you're doing everything properly.

alt tag

Now depending on what you'd like to change you should implement a particular protocol providing methods for customizing that stuff. For delegates' API description take a look at [this page] (https://github.com/CVCalendar/CVCalendar/wiki).

Do NOT forget to connect a particular outlet with your ViewController if you're implementing its protocol.

NOTE: CVCalendar defines default values for all the customizable properties (i.e. for ones defined in the presented protocols). Thus far if you don't implement protocols yourself the calendar will behave as it was initially designed.

Manual Setup

If for some reason you'd like to setup CVCalendar manually you have to do the following steps.

Initialize CVCalendarView with either init or init:frame methods. I suggest to do it in viewDidLoad method. Do NOT put initialization in viewDidAppear: or viewWillAppear: methods! Then setup delegates if you're going to customize options.

Note that CVCalendarAppearanceDelegate should be set before CVCalendarViewDelegate so your changes can be applied.

For CVCalendarMenuView you simply initialize it as well as CVCalendarView and it requires to implement CVCalendarMenuViewDelegate protocol.

How it should look like.

    override func viewDidLoad() {
        super.viewDidLoad()

        // CVCalendarMenuView initialization with frame
        self.menuView = CVCalendarMenuView(frame: CGRectMake(0, 0, 300, 15))

        // CVCalendarView initialization with frame
        self.calendarView = CVCalendarView(frame: CGRectMake(0, 20, 300, 450))

        // Appearance delegate [Unnecessary]
        self.calendarView.calendarAppearanceDelegate = self

        // Animator delegate [Unnecessary]
        self.calendarView.animatorDelegate = self

        // Menu delegate [Required]
        self.menuView.menuViewDelegate = self

        // Calendar delegate [Required]
        self.calendarView.calendarDelegate = self
    }

And do not forget to commit updates on viewDidLayoutSubviews method.

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()

        // Commit frames' updates
        self.menuView.commitMenuViewUpdate()
        self.calendarView.commitCalendarViewUpdate()
    }

Here you go.

Architecture

Version matrix

CVCalendar adapts the newest swift language syntax but keeps revisions as stated below:

CVCalendar Swift Xcode Release Notes
1.6 4.x 8.x, 9.x, 10.x HEAD
1.5 3.x 8.x, 9.x swift3-branch
1.4 3.x 7.x, 8.0 Unsupported
1.3 2.x 7.x Unsupported
1.2 1.x 7.x Unsupported

Advanced API

For contributors

If you've any remarks please feel free to open up an issue or submit PRs. Please make sure to adhere to the provided issue template while doing so. Also note that the Demo project is supposed to test the changes on CVCalendar. If you've committed any, do not forget to check if everything compiles and works as intended and update the docs accordingly. Thanks ๐Ÿ‘

Comments
  • supplementaryView shown on wrong day

    supplementaryView shown on wrong day

    simulator screen shot dec 21 2016 10 06 42 am

    • [ X] I have verified there are no duplicate active or recent bugs, questions, or requests
    • [ X] I have verified that I am using the latest version of CVCalendar.
    • [ X] I have given my issue a non-generic title.

    Expected Behavior

    I modified the demo to show a circle on a specific day (02 Dec 2016).

    This is how the framework worked a few weeks ago.

    Current Behavior

    With the modification - The supplementaryView shows on the wrong date (28 Dec 2016)

    This was not how this worked just a month ago. When I upgrade my project that just got approved in the App Store, all my "event" dates are now broken and circling the wrong dates!

    Possible Solution

    Steps to Reproduce (for bugs)

    1. Download the latest demo
    2. Replace the func that show random supplementaryViews with a concrete date
    func supplementaryView(shouldDisplayOnDayView dayView: DayView) -> Bool {
            if let convertedDate = dayView.date.convertedDate(calendar: Calendar.current)  {
              
              let cal = Calendar.current
              var components = DateComponents()
              components.day = 2
              components.month = 12
              components.year = 2016
              let testDate = cal.date(from: components )
              
              if testDate == convertedDate {
                return true
              }
              
            }
            
            return false
        }
    
    1. Run the demo and observe date "circled" is not 02 Dec 2016, but 28 Dec 2016

    Context

    I discovered this trying to find a work around for issues I uncovered putting the calendar view in a UI Stackview. First I though my fixes for that issue were causing these random supplementary views to appear. It was only when I backed out all my changed that I uncovered this one too.

    opened by DannyJi 35
  • Loading dates on calendar from remote JSON web service

    Loading dates on calendar from remote JSON web service

    Hello, thank you for the t great library. I was wondering if is there any suggested way to load dates from web service to a monthview, in cvcalendar?

    I can across library references and issues , but I'm not sure what to do. One ref is : https://github.com/Mozharovsky/CVCalendar/issues/80. Lets say i have an array with month dates, which function should be used to load em to calendar? Excuse me in advance if i missed or didn't see something from documentation or issues but need some help.

    Thank you

    opened by coanag 26
  • Selected date disappears when changing orientation

    Selected date disappears when changing orientation

    • [X] I have verified there are no duplicate active or recent bugs, questions, or requests
    • [X] I have verified that I am using the latest version of CVCalendar.
    • [x] I have given my issue a non-generic title.

    Expected Behavior

    Selected day should not disappear on orientation change.

    Current Behavior

    After calendarView loads and the device is rotated once or twice (not consistent) the current selected day disappears. It shows up again when changing the date to a different date.

    Steps to Reproduce (for bugs)

    1. Load calendarView (portrait) and select any date (10th in my case)
    screen shot 2017-10-12 at 4 52 36 pm
    1. Rotate device (calendarView doesn't resize properly on iPhones but we've always had that issue. That's another issue)
    screen shot 2017-10-12 at 4 52 54 pm
    1. You can rotate it back to portrait mode. Selected view is still gone
    screen shot 2017-10-12 at 4 53 12 pm
    1. In order to get day back, a different date needs to be selected (11th in my case)
    screen shot 2017-10-12 at 4 53 27 pm

    Context

    If selected date doesn't disappear on the first rotation, try to rotate a second time. The latest version that did not have this issue is 1.4.1

    Your Environment

    • Version used (Cocoapods spec): 1.6.0
    • Devices used: Simulator - iPhone SE, iPhone X, iPad Pro. Physical Device: iPad Mini 4th gen.
    bug orientation change Stale 
    opened by cherick04 24
  • Can't run on iPhone 4 (7.1.2)

    Can't run on iPhone 4 (7.1.2)

    Hi, i tried run cvCalendar-Demo on my iPhone 4 (7.1.2) but getting error "2015-01-14 13:07:06.278 CVCalendar Demo[479:60b] Could not load the "present-100" image referenced from a nib in the bundle with identifier "com.gameapp.production.CVCalendar-Demo"

    i delete present-100 image but getting another error

    fatal error: unexpectedly found nil while unwrapping an Optional value on startup untitled

    i set deployment target 7.1 it running on simulator but doesn't run on iPhone

    Thanks

    bug help wanted 
    opened by quattrogecko 23
  • Swift 2.0 support

    Swift 2.0 support

    I notice there's no Swift-2.0 branch for CVCalendar.

    Has Swift 2.0 support been considered? What is the migration strategy?

    (Note, "Pull Requests gratefully accepted" is a valid response to this issue :-)

    opened by ratkins 21
  • Change the month and the app goes in crash!!!

    Change the month and the app goes in crash!!!

    • [Y] I have verified there are no duplicate active or recent bugs, questions, or requests
    • [Y] I have verified that I am using the latest version of CVCalendar.
    • [Y] I have given my issue a non-generic title.

    Expected Behavior

    When I open the calendar should then change the month if required

    Current Behavior

    The app crashes when I change the month

    Possible Solution

    I have no idea

    Steps to Reproduce (for bugs)

    1. I open the calendar and everything works, the days vengoni circled and everything is ok
    2. Change the month and the app goes in crash
    3. It returns this error in the "func supplementaryView (shouldDisplayOnDayView dayview: DayView)": "Fatal error: unexpectedly found nil value while unwrapping an Optional" The offending line is: let dateformatter NSDateFormatter = () dateformatter.dateFormat = "dd / mm / yyyy" let data = dateformatter.stringFromDate (dayView.date.convertedDate ()!) Where "Date" = "" to the compiler

    Context

    Should function with that circle the days that have events, as soon as I open the calendar happens!

    Your Environment

    I did not touch anything, just updated the CVCalendar folder.

    opened by schulz89sp 19
  • How to preselect a date interval programmatically?

    How to preselect a date interval programmatically?

    • [x] I have verified there are no duplicate active or recent bugs, questions, or requests
    • [x] I have verified that I am using the latest version of CVCalendar.
    • [x] I have given my issue a non-generic title.

    How to preselect a date interval programmatically? @elsesiy

    Stale awaiting user input 
    opened by Ewg777 17
  • AutoLayout issue

    AutoLayout issue

    When testing this against different size classes, the calendar doesn't appears to resize itself properly.

    Here is a screenshot of the calendarView stretched in the horizontal orientation of the iPhone 6S Plus.

    screen shot 2015-11-09 at 6 23 14 pm Stale 
    opened by anthonycastelli 17
  • Refresh calendar (dotMarkers)

    Refresh calendar (dotMarkers)

    Hello,

    First of all, I wanted to congratulate you and thank you for you great CVCalendar !

    I'm currently trying to use your CVCalendar from the 'Develop' branch as I recently upgraded to Xcode 6.3 and Swift 1.2, and I'm struggling to refresh (update / reload) the multiple dotMarkers. I'm using the main view controller from a TabBarController, so the viewDidLoad function is only called once. I've tried many things (func viewDidAppear() / func viewDidLayoutSubviews()) to refresh the dotMarkers accordingly to my data being refreshed. For instance, when deleting or adding an event, my TableView will update with the changes made but not the dotMarkers presented on the calendar. To refresh, the calendar I need to restart the application and then it works.

    Could you please help me ?

    Also, I wanted to know when your CVCalendar will be fully operational for swift 1.2 ?

    Many thanks (in advance) !

    enhancement help wanted question auxiliary views 
    opened by MlM7Studios 17
  • Calendar reload

    Calendar reload

    There should be a way to reload the calendar. I fetch data (calendar events) from a server and I want to add a dot for them on the calendar, but there isn't a way to trigger the calendar to reload after the data is received. Are there any plans to add such a method or is there a way I can force it to reload?

    opened by anthonycastelli 16
  • Top markers disappear upon beginning to swipe to new month

    Top markers disappear upon beginning to swipe to new month

    • [x] I have verified there are no duplicate active or recent bugs, questions, or requests
    • [x] I have verified that I am using the latest version of CVCalendar.
    • [x] I have given my issue a non-generic title.

    Behavior

    When I start to swipe between months, the top markers disappear. The next month's top markers are visible while swiping, and remain visible upon releasing the touch, but as soon as I begin to swipe again that month's top markers disappear.

    I'm not sure the cause of the issue. But perhaps it's related to the fact it's only 0.5pt tall. I would love the ability to set its height - I would use 1pt for example.

    Steps to Reproduce

    1. Create a calendar month view with topMarkerShouldDisplayOnDayView returning true
    2. Begin to swipe the calendar Results: Top markers disappear for this month, but are visible for the upcoming month

    ezgif-1-d18f507031b4

    Your Environment

    • Version used: 1.6.2
    • Device used: Simulator (iOS 12.1)
    Stale awaiting user input 
    opened by hipwelljo 14
  • remove subviews of menu before adding new labels

    remove subviews of menu before adding new labels

    This PR has the following changes:

    • Removed subviews of calendar menu before adding new labels

    Issue: createDaySymbols function, add new labels to the menu without deleting existing labels.

    Stale 
    opened by kevalvadoliya 1
  • I need to set min and max date

    I need to set min and max date

    • [x] I have verified there are no duplicate active or recent bugs, questions, or requests
    • [x] I have verified that I am using the latest version of CVCalendar.
    • [x] I have given my issue a non-generic title.
    Stale 
    opened by waqar1992 1
  • Add shouldSelect option in togglePresentedDate method

    Add shouldSelect option in togglePresentedDate method

    Add shouldSelect option parameter in togglePresentedDate method. This determines whether selectDayViewWithDay method where is in the end of togglePresentedDate method should be called or not.

    I set true as default value for shouldSelect to support legacy codes.

    AS-IS (CVCalendarContentViewController) @objc public func togglePresentedDate(_ date: Foundation.Date) { }

    TO-BE @objc public func togglePresentedDate(_ date: Foundation.Date, shouldSelect: Bool = true) { }

    This may helps https://github.com/CVCalendar/CVCalendar/issues/251 although it's closed.

    Stale 
    opened by yoobato 1
  • Show only two weeks.

    Show only two weeks.

    Hello. Thank you for this calendar. In library i see week mode (show only one week) and month mode.

    Do you have some methods (or what i can change) to show last 2 weeks?

    Stale 
    opened by burla69 1
Releases(1.7.0)
Owner
null
RCalendarPicker A date picker control, Calendar calendar control, select control, calendar, date selection, the clock selection control.

RCalendarPicker RCalendarPicker Calendar calendar control, select control, calendar, date selection, the clock selection control. ๆ—ฅๅŽ†ๆŽงไปถ ๏ผŒๆ—ฅๅŽ†้€‰ๆ‹ฉๆŽงไปถ๏ผŒๆ—ฅๅŽ†๏ผŒๆ—ฅๆœŸ้€‰ๆ‹ฉ

ๆœ่€€่พ‰ 131 Jul 18, 2022
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
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 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
Calendar component with RTL languages written in swift

GDCalendar Calendar component with both RTL/LTR languages support with Swipe Gesture enabled navigation. Easy to use with Storyboard and Attributes In

Saeid 26 Jul 17, 2022
Clendar - universal calendar app. Written in SwiftUI. Available on App Store. MIT License.

Clendar - minimal calendar Minimal Calendar & Widgets Landing Page About This project is started out as an UIKit base app for me to learn new WWDC fea

Vinh Nguyen 418 Dec 30, 2022
๐Ÿ“… 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
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 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
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
๐Ÿ“† An elegant calendar control for iOS.

NO LONGER MAINTAINED Daysquare An elegant calendar control for iOS. Introduction Get bored with native silly UIDatePicker? You may have a try on this

Cyandev 701 Sep 9, 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
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
Simplifies iOS user permission requests (location, push notifications, camera, contacts, calendar, photos, etc).

ICanHas Swift 4 library that simplifies iOS user permission requests (push notifications, location, camera, photo library, contacts, calendar). Instal

Adolfo Rodriguez 91 Jun 2, 2022