The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable

Overview

jtapplecalendarnewlogo

Tutorial Version Carthage Compatible Platform License Backers on Open Collective Sponsors on Open Collective Open Source Helpers

Q: How will my calendar dateCells look with this library?

A: However you want them to look.

More Images

Features


  • Range selection - select dates in a range. The design is entirely up to you.
  • 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

How do I use this library?

>> Read the wiki for Tutorials and example code to download. Or visit PatchTheCode.com.


Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

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

Comments
  • scrollingMode nonStopToSection(withResistance: CGFloat) skipping section

    scrollingMode nonStopToSection(withResistance: CGFloat) skipping section

    1. PLEASE STATE THE VERSION NUMBER you are using. 7.1.4
    2. Are you using the latest version of JTAppleCalendar? Yes
    3. PROVIDE ENOUGH INFORMATION SO I CAN RECREATE THE PROBLEM. I have a vertical scrolling calendar setup with nonStopToSection as scrollingMode. The issue I see is that not always stop on the next section (month), sometimes it skips a month and I have to try multiple times to get it stop, even give just the right amount of inertia to get it in the month I want to eventually stop.

    I'm not able to repro on 7.0.6. I jumped from that version to the latest one in which I observe the issue. https://github.com/patchthecode/JTAppleCalendar/compare/7.0.6...7.1.4

    vertical_scrolling_issue

    bug Already Fixed on Master Branch 
    opened by mgurreta 43
  • Things go crazy with

    Things go crazy with "Hide Bottom Bar on Push" - Progress to Infinite Scrolling

    So the latest commits fixed the problem with the infinite scrolling, but they created another problem:

    If you have the calendar on a view controller embedded on a tab bar controller and you push a new view controller on top of it using the option "Hide Bottom Bar on Push", when you go back to the calendar it's all wrong. It was driving me crazy, took me forever to realize the problem was that option.

    I added an example here: https://github.com/dbmrq/JTCalTest/tree/third-attempt

    Check out the third-attempt branch, run the app, go to the second tab, tap the "Push VC" row and then go back to the previous VC. You'll see the calendar flashes and ends up at the wrong section. Then if you disable the "Hide Bottom Bar on Push" option on the second VC and try again it all works fine. This wasn't happening a month ago, so it was caused by something on the last few commits.

    That happens because I set the calendar height to be half the height of the view controller. So when you push a view controller without the tab bar and then go back to the controller with the tab bar it thinks the size changed and the calendar reloads and messes things up. So for now I can work around this by setting an explicit height for the calendar view, but this wasn't happening before, and I think it would be better if we could change the height without any problems. Whatever the calendar view does when its height changes, it should do it before it's even visible, and it should come back to the same section it was at before, so the change wouldn't be visible at all, instead of the flash we're getting now.

    Like I said, for now I can just set the height explicitly, so this isn't such a big deal, but I thought you should know about it. Cheers. :)

    opened by dbmrq 43
  • Style, naming and other minor nitpicking

    Style, naming and other minor nitpicking

    You asked if I had any other suggestions… well, JTAppleCalendar is already awesome, and it works great, but here are a few thoughts, mostly just some tiny details that I think could be improved.

    Take these methods, for instance:

    func configureCalendar(calendar: JTAppleCalendarView)
    
    func calendar(calendar : JTAppleCalendarView, isAboutToResetCell cell: JTAppleDayCellView){}
    

    Why is the colon next to calendar in the first case but separated with a space in the second? There are many other similar inconsistencies. I suggest you give SwiftLint a try. I can set it up at the demo project if you're interested.

    Also, why the name isAboutToResetCell instead of the standard willResetCell? Apple has some guidelines about that here.

    And speaking of naming conventions, I didn't really take a deep look at the changes in swift 3 yet, but I think according to the new convention (check the second item, "omit needless words") that method should read isAboutToReset cell: JTAppleDayCellView instead of isAboutToResetCell cell: JTAppleDayCellView. There are many other examples like that, and since swift 3 already makes a lot of those breaking changes it's a great excuse to make them here too I think.

    Also, since you already follow the way table views work, why use that calendarView.registerCellViewXib(fileName: "CellView") property instead of a delegate method like cellForDayAtDate (like you have cellForRowAtIndexPath for table views)? Then the user would be able to configure the cell right in the view controller where it will be displayed, instead of cramming the code in the cell class. (How many lines do your UITableViewCell classes have? A lot less than your JTAppleDayCellView classes, I bet.) Also that would allow the user to add the cell view straight to the view controller the calendar view is in (like it is with UITableViews), instead of having to add a dedicated xib. And the cell view class would be a lot easier to repurpose.

    Lastly, this may by a little more tricky and it's not essential, but since you seem to be making some big changes already, here's another suggestion. I think it would be better if the calendar didn't have those startDate and endDate limits. It would just have an initial date that could default to today, and then the UICollectionView would be created with 3 months, the current month, the month before and the month after. When the user scrolled to the next month, one more month would be added after that one, and so on. And if the user wanted he could set a property like calendarView.maxDate.

    As I said, these are all just suggestions, feel free to ignore them if you prefer. JTAppleCalendar is really great already. :)

    This is not a bug. Works as expected. 
    opened by dbmrq 43
  • Range with zero spacing between cells issue

    Range with zero spacing between cells issue

    Hi

    I want to achieve range selection with zero space between cells But I have white spaces between cells so sometimes cell occurred to be less in width than others

    I'm not altering cell size programmatically.

    In storyboard I have image with trailing leading bottom and top constraints to cell in calendar cell width and height is set up to 50 and cell size is 0 (like in example app)

    Maybe I'm missing something when using library or maybe there is some issue for calculating cell width and height (I have tried different ratio for calendar width and height: square and rectangles )

    Thanks in advance!

    screen shot 2017-08-21 at 16 50 25

    opened by romaHerman 41
  • Given an array of saved dates, how to do i select a number of dates on the calendar?

    Given an array of saved dates, how to do i select a number of dates on the calendar?

    I have an array of dates (that user previously tapped) and I'm trying display them on a calendar by assigning them isSelected = true, but I can't because Xcode tells me isSelected is a let.

    Is there some workaround to this?

    enhancement 
    opened by antonijap 40
  • Option for Persian/Jalali Calendar?

    Option for Persian/Jalali Calendar?

    I made some change in source code and It's changed to Persian calendar and Right to Left. I just want to know is it OK if I change some code in this framework?

    enhancement 
    opened by vahids 39
  • Repeated week between two months with one row calendar

    Repeated week between two months with one row calendar

    Hi @patchthecode I'm using your calendar in one row mode to have a week view. I have a strange behaviour and I don't know if it's a bug or a misconfiguration problem. Here's the thing, suppose that I'm in this situation, with a week between two months: img_0068

    If I scroll left, I would like to see the week from august 22nd to august 28th, but Instead I find another time this: img_0069

    And then, if I scroll again left I find this img_0070

    And scrolling again to the left I finally find the week from august 22nd to august 28th I use dark gray in the day names for current month names and light gray for other months' day. It's like there is an extra and useless week between two months. This happens every time when I'm scrolling from a month to another.

    Here is the initialization code:

    calendarView.dataSource = self
    calendarView.delegate = self
    calendarView.registerCellViewXib(fileName: cellXibName)
    calendarView.cellInset = CGPoint(x: 0, y: 0)
    calendarView.firstDayOfWeek = .Monday
    calendarView.reloadData()
    calendarView.selectDates([NSDate()])
    calendarView.scrollToDate(NSDate(), triggerScrollToDateDelegate: false, animateScroll: false, preferredScrollPosition: .None, completionHandler: nil)
    

    and here is the configureCalendar Method from the delegate

    func configureCalendar(calendar: JTAppleCalendarView) -> (startDate: NSDate, endDate: NSDate, numberOfRows: Int, calendar: NSCalendar) {
        var numberOfRows = 6
        if let calendarView = calendar as? AddictionJTAppleCalendarView{
            numberOfRows = calendarView.configuredNumberOfRows
        }
        let aCalendar = NSCalendar.currentCalendar()
        return (startDate: CalendarDateManager.sharedInstance.calendarStartDate, endDate: CalendarDateManager.sharedInstance.calendarEndDate, numberOfRows: numberOfRows, calendar: aCalendar)
    }
    

    Am I doing something wrong or is a bug? Thanks in advance, and CONGRATULATIONS, this is by far the best calendar plugin, thank you so much for having developed it!!!!

    duplicate Already Fixed on Master Branch 
    opened by allemattio 39
  • scrollToDate() does not account for UICollectionView sectionInset property

    scrollToDate() does not account for UICollectionView sectionInset property

    First - thanks for all your hard work on this calendar! I am using JTAppleCalendar 7.02.

    Calling calendarView.scrollToDate(Date(), triggerScrollToDateDelegate: true, animateScroll: false) I noticed that the collection view was stopping between April & May. I played around with the extraAddedOffset and realized the issue was related to the Section Inset.

    The offset amount I needed to move the view into the correct position was 160pt. This is because the offset for each section increases by 40 so for 4 sections (jan through apr), the offset must be increased by 40 for each month (160). I'm not sure if it was intentional or not but thought I should bring it up.

    The solution for now is to either not use section inset or to multiply the Integer month by the total inset amount and set that as the extraAddedOffset.

    screenshot 2017-05-17 14 34 43 bug Already Fixed on Master Branch 
    opened by johnuphoff 37
  • Range selection question

    Range selection question

    I am using 7.1.5

    I have set up as shown below. I have given different colors ( and uiview shapes) for the cell based on the selectionRangePosition. In my app logic, when the user selects 27 ( the first date) , then selects a second date ( April 1 in this case) , then all the dates in between will be selected.

    In the image below , I expect the selected date of March 31 to be a cell of type .middle. I am not sure why it shows both the .left and .right views , could you please let me know.

    Screen Shot 2019-03-14 at 11 28 27 AM bug Already Fixed on Master Branch 
    opened by ThasneemH 33
  • Crash when switching numberOfRows to 1, then back to 6 and modifying the calendars height

    Crash when switching numberOfRows to 1, then back to 6 and modifying the calendars height

    When I trying to switch calendar to the week mode and back by setting numberOfRows to 1 and then back to 6, simultaneously modifying the calendars height I have the crash:

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete item 36 from section 0 which only contains 7 items before the update'

    I've attached the sample project where this crash can be reproduced by clicking Jan 31 for 3 times

    Sample

    Sample project: https://www.dropbox.com/s/lle6kuf93n8ptbi/CrashTest.zip?dl=0

    bug Already Fixed on Master Branch 
    opened by numen31337 33
  • Calendar Grid is not fully 0,0 when set to 0,0 Cell inset. It is off by one pixel when orientation changes. This seems to be an iOS issue. Workaround for now is to set the inset to some negative fractional value if you are experiencing the issue.

    Calendar Grid is not fully 0,0 when set to 0,0 Cell inset. It is off by one pixel when orientation changes. This seems to be an iOS issue. Workaround for now is to set the inset to some negative fractional value if you are experiencing the issue.

    I have a three month calendar (June - Aug, 2016). I've attached three images.

    First is how the calendar initially appears, second is when I scroll from June to July and third is when I scroll back to June.

    Here's the additional code in my controller:

        calendarView.dataSource = self
        calendarView.delegate = self
        calendarView.registerCellViewXib(fileName: "ScheduleCellView")
        calendarView.backgroundColor = UIColor.whiteColor()
        calendarView.cellInset = CGPoint(x: 2, y: 2)
    
        let currentDate = calendarView.currentCalendarDateSegment()
        setupViewsOfCalendar(currentDate.startDate, endDate: currentDate.endDate)
    

    setupViewsOfCalendar is from the tutorial.

    screenshot 2016-05-24 10 39 52 screenshot 2016-05-24 10 40 04 screenshot 2016-05-24 10 40 20 bug help wanted 
    opened by cbwilliamsnh 33
  • Is it possible to configure like carousel calendar view?

    Is it possible to configure like carousel calendar view?

    (Required) Version Number: 8.0.2

    Description

    I want to integrate the changes like current month will see in center, previous and next month will see at side of the current month like Carousel View. So what we need to change for achieve this feature from your library? Is it possible in your library?

    Please update as early as possible.

    opened by Nik20112 7
  • didScrollToDateSegmentWith working when click to cell in iphoneX

    didScrollToDateSegmentWith working when click to cell in iphoneX

    **(Required) Version Number:**8.0.3

    Description

    In Iphone X, when I click to cell in collectionView, function didScrollToDateSegmentWith working cause some actions to go wrong

    Steps To Reproduce

    Step 1 : Setup normal Calendar Step 2 : Click to cell in collectionView on device iphone X Step 3 : Debug in function didScrollToDateSegmentWith

    Expected Behavior

    didScrollToDateSegmentWith not working when click to cell

    Additional Context

    didScroll do the task of calling API , when click duplicate calling API

    opened by hoangnv98 3
  • How to remove cell's border line

    How to remove cell's border line

    JTAppleCalendar (8.0.4)

    I tried to remove cell border line from the SampleJITAppleCalender, however I could not find any codes to create cell border line. So I create my own code to initialize JTAppleCalendar by copying CellView.xib as follows.

    override func viewDidLoad() { super.viewDidLoad() print("viewDidLoad CalenderVC") tableView.delegate = self tableView.dataSource = self as UITableViewDataSource

        let nibName = UINib(nibName: "CellView", bundle:Bundle.main)
        calendarView.register(nibName, forCellWithReuseIdentifier: "CellView")
        calendarView.scrollToDate(Date())
        calendarView.calendarDataSource  = self
        calendarView.calendarDelegate  = self
        self.calendarView.visibleDates {[unowned self] (visibleDates: DateSegmentInfo) in
            self.setupViewsOfCalendar(from: visibleDates)
        }
        calendarView.allowsMultipleSelection = false
        calendarView.minimumLineSpacing = 0
        calendarView.minimumInteritemSpacing = 0
        calendarView.scrollingMode = allScrollModes[6]
        
        selectDate = Date()
        readEventsForThisMonth()
    }
    

    [JTAPPLECalendar ScreenShot] (https://user-images.githubusercontent.com/25836706/198818808-15dddf08-d258-4a52-b1dd-ea2bb785ae83.png)

    Please advise me how to remove the border line from the cells. Thank you.

    opened by ymatt345 2
  • accessibility for visibleDates cells

    accessibility for visibleDates cells

    JTAppleCalendar Version Number: 8.0.2

    Description

    Hello, I'm working on a client's app that uses this great library. I've been stuck at the issue below, it's probably simple but I haven't figured out. Any pointers or support would be greatly appreciated.

    The app uses a date-picker calendar with a 'from' and 'to' dates to filter out health-related data with a custom date from the past 6 months. The view has one calendar showing the month with a 'from' or 'to' dates, and the other months can be navigated horizontally with the back and forth buttons. Given an inStartDate and inEndDate, I'm able to get all the accessibility elements for the dateCells within that range, but what I'm trying to achieve is to find only the elements for the visibileDates/visibleCells of the current month being shown, and one month at a time. Please advise what can be done to resolve this.

    Please ignore the 'range' selectionType in the attached picture, I'm using the '.date' selectionType. Sorry for my English, hopefully you understand the issue.

    exampleCalendar

    opened by inspiredlearner 1
  • Correct numerical errors in roundedFrameSection calculation

    Correct numerical errors in roundedFrameSection calculation

    In my project, I have a calendar view that scrolls horizontaly one month at a time:

    image

    When calling calendar.scrollToDate(), the calendar was scrolling to the wrong month anytime the specified date was a Sunday. Specifically, it was scrolling to the next previous month.

    The problem is due to the formula floor(frameSection) in targetPointForItemAt(). Naturally, frameSection may have small numerical errors. For example, a Sunday may yield frameSection == 49.9999999999999. However, floor(49.9999999999999) == 49 when the correct calculation should be 50.

    One potential fix, which is the one I'm submitting in this PR, is to reduce the numerical precision of frameSection from double to single before calling floor(). This correctly results in floor(50) == 50.

    opened by wtmoose 0
Owner
PatchTheCode
[John 3:16] - For God so loved the world, that he gave his only begotten Son, that whosoever believes in him should not die, but have life eternal. Jesus Saves
PatchTheCode
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
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
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
A fully customizable calendar view acting as a date range picker

Demo Installation CocoaPods With CocoaPods you can simply add GLCalendarView in your Podfile: pod "GLCalendarView", "~> 1.0.0" Source File You can co

Glow Inc 860 Nov 18, 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
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
📆 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
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
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 customizable swiftui calendar

Description not available. Installation From Xcode 11, you can use Swift Package Manager to add Kingfisher to your project. Select File > Swift Packag

Heshan Yodagama 140 Dec 24, 2022
An Event View based on Apple's Event Detail View. Written in Swift 3. Supports ARC, Autolayout and editing via StoryBoard.

An Event View based on Apple's Event Detail View. Written in Swift 3. Supports ARC, Autolayout and editing via StoryBoard. Installation CocoaPods PTEv

Aman Taneja 36 Oct 5, 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 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
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
Full featured lunar calendar library

LunarCore 小历(iOS & OS X)的农历核心部分。 何为小历 小历是一个简洁的农历 app,目前支持 iOS & OS X 两端,iOS 端多次被 App Store 官方推荐。 前世今生 LunarCore 最早来自于一个 JavaScript 编写的农历库:LunarCalenda

Ying Zhong (Inactive) 782 Aug 31, 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 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
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