A fully customizable iOS calendar library, compatible with Objective-C and Swift

Overview

logo

Apps Using Total Downloads
Travis Version Platform Carthage compatible
Languages

Table of contents

Screenshots

iPhone

fscalendar

iPad

fscalendar-ipad

Safe Orientation

fscalendar-scope-orientation-autolayout

Today Extension

iOS8/9 iOS10
today1 today2

Interactive Scope Gesture

1

DIY support

1

To customize your own cell, view DIY Example in Example-Swift or Example-Objc

Swipe-To-Choose

Single-Selection
Swipe-To-Choose
Multiple-Selection
Swipe-To-Choose
DIY
Swipe-To-Choose
1 2 3

Achievement of Users

1 2 3 4

More Achievements are available in FSCalendar Gallery

Installation

CocoaPods:

  • For iOS8+: 👍
use_frameworks!
target '<Your Target Name>' do
    pod 'FSCalendar'
end
  • For iOS7+:
target '<Your Target Name>' do
	pod 'FSCalendar'
end

NSCalendarExtension is required to get iOS7 compatibility.

Carthage:

  • For iOS8+
github "WenchaoD/FSCalendar"

SPM:

Add dependency:

.package(url: "https://github.com/WenchaoD/FSCalendar.git", from: "2.8.3")

Manually:

  • Drag all files under FSCalendar folder into your project. 👍

Alternatively to give it a test run, simply press command+u in Example-Objc or Example-Swift and launch the UITest Target.
Only the methods marked " 👍 " support IBInspectable / IBDesignable feature. Have fun with Interface builder

Setup

Use Interface Builder

1、 Drag an UIView object to ViewController Scene 2、 Change the Custom Class to FSCalendar
3、 Link dataSource and delegate to the ViewController

fscalendar-ib

4、 Finally, implement FSCalendarDataSource and FSCalendarDelegate in your ViewController

Or use code

@property (weak , nonatomic) FSCalendar *calendar;
// In loadView(Recommended) or viewDidLoad
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
calendar.dataSource = self;
calendar.delegate = self;
[self.view addSubview:calendar];
self.calendar = calendar;

Or swift

fileprivate weak var calendar: FSCalendar!
// In loadView or viewDidLoad
let calendar = FSCalendar(frame: CGRect(x: 0, y: 0, width: 320, height: 300))
calendar.dataSource = self
calendar.delegate = self
view.addSubview(calendar)
self.calendar = calendar

To use FSCalendar in Swift3, see Example-Swift for details.

Warning

FSCalendar doesn't update frame by itself, Please implement

  • For AutoLayout
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
    self.calendarHeightConstraint.constant = CGRectGetHeight(bounds);
    // Do other updates here
    [self.view layoutIfNeeded];
}
  • For Manual Layout
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
    calendar.frame = (CGRect){calendar.frame.origin,bounds.size};
    // Do other updates here
}
  • If you are using Masonry
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
    [calendar mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(bounds.size.height));
        // Do other updates
    }];
    [self.view layoutIfNeeded];
}
  • If you are using SnapKit
func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
    calendar.snp.updateConstraints { (make) in
        make.height.equalTo(bounds.height)
        // Do other updates
    }
    self.view.layoutIfNeeded()
}

Roll with Interface Builder

fscalendar - ibdesignable

Pre-knowledge

In Swift3, NSDate and NSDateFormatter have been renamed to Date and DateFormatter , see Example-Swift for details.

How to create NSDate object

  • By NSCalendar.
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];

Then:

NSDate *date = [gregorian dateWithEra:1 year:2016 month:9 day:10 hour:0 minute:0 second:0 nanosecond:0];
// 2016-09-10 00:00:00
  • Or by NSDateFormatter
self.formatter = [[NSDateFormatter alloc] init];
self.formatter.dateFormat = @"yyyy-MM-dd";

Then:

NSDate *date = [self.formatter dateFromString:@"2016-09-10"];

How to print out NSDate object

  • Use NSDateFormatter
self.formatter = [[NSDateFormatter alloc] init];
self.formatter.dateFormat = @"yyyy/MM/dd";
NSString *string = [self.formatter stringFromDate:date];
NSLog(@"Date is %@", string);

How to manipulate NSDate with NSCalendar

self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
  • Get component of NSDate
NSInteger era = [self.gregorian component:NSCalendarUnitEra fromDate:date];
NSInteger year = [self.gregorian component:NSCalendarUnitYear fromDate:date];
NSInteger month = [self.gregorian component:NSCalendarUnitMonth fromDate:date];
NSInteger day = [self.gregorian component:NSCalendarUnitDay fromDate:date];
NSInteger hour = [self.gregorian component:NSCalendarUnitHour fromDate:date];
NSInteger minute = [self.gregorian component:NSCalendarUnitMinute fromDate:date];
...
  • Get next month
NSDate *nextMonth = [self.gregorain dateByAddingUnit:NSCalendarUnitMonth value:1 toDate:date options:0];
  • Get next day
NSDate *nextDay = [self.gregorain dateByAddingUnit:NSCalendarUnitDay value:1 toDate:date options:0];
  • Is date in today/tomorrow/yesterday/weekend
BOOL isToday = [self.gregorian isDateInToday:date];
BOOL isYesterday = [self.gregorian isDateInYesterday:date];
BOOL isTomorrow = [self.gregorian isDateInTomorrow:date];
BOOL isWeekend = [self.gregorian isDateInWeekend:date];
  • Compare two dates
BOOL sameDay = [self.gregorian isDate:date1 inSameDayAsDate:date2];
// Yes if the date1 and date2 are in same day


[self.gregorian compareDate:date1 toDate:date2 toUnitGranularity:unit];
// compare the era/year/month/day/hour/minute .etc ...
// return NSOrderAscending/NSOrderSame/NSOrderDecending

BOOL inSameUnit = [self.gregorian isDate:date1 equalToDate:date2 toUnitGranularity:unit];
// if the given unit (era/year/month/day/hour/minute .etc) are the same

Support this repo


* Support with  
* Support with or

Contact

If your made a beautiful calendar with this library in your app, please take a screen shot and @me in twitter. Your help really means a lot to me!

License

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

Documentation | More Usage | 简书

Comments
  • Is it possible to display 2 weeks instead of 1 week?

    Is it possible to display 2 weeks instead of 1 week?

    screen shot 2016-11-04 at 6 53 22 pm

    Please see the screenshot. The calendar used to display two weeks. But I upgraded FSCalendar when I inherited the project. Is this still possible with the current version?

    opened by Jamongkad 30
  • How to hide days not in current month?

    How to hide days not in current month?

    Hi Wenchao,

    Is there a way to:

    1. Hide days not in their current month?
    2. Hide the the separator between month header and weekday header? I uploaded a image below to illustrate this: screen shot 2015-12-20 at 11 18 21 pm

    Thanks for creating this awesome library! It's very easy to use and highly customizable.

    opened by chuanghan 22
  • Is it possible to make event indicators have different colors each?

    Is it possible to make event indicators have different colors each?

    Rather than having a single color for all event indicators, would it be possible to have different colors for each event depending on the nature of the event for example?

    opened by cyrilzakka 21
  • Interface builder - FSCalendar - Designables - Build Failed

    Interface builder - FSCalendar - Designables - Build Failed

    The following informations are requested in a bug report

    • A brief bug description. I've upgraded to use use_frameworks! as I thought the designables build failed error was the caused by this. When I click on show to see the error, it shows nothing relevant only a working copy error.

    • Stack trace. None.

    • Integration method.(manually/cocoapods/carthage) Cocoapods

    • Full steps to reproduce. Add the FSCalendar to a view, Build Failed error is produced.

    • Device modal and iOS version. e.g. iPhone 6s iOS9.1 iOS8.0

    • Xcode version. e.g. Xcode 8.1 Xcode 8.1

    • FSCalendar version. e.g. FSCalenda 2.5.1 FSCalendar (2.6.0)

    • Does this happen in the demo project? Which one? Or a link to another demo project. Yes, the objective-c demo, I haven't tried the swift demo.

    opened by JulesMoorhouse 20
  • Post appearance image/itunes address here

    Post appearance image/itunes address here

    If you are using this calendar, please take a screen shot and post the image here, this would help me and others get better idea for color matching. e.g appearance05

    opened by WenchaoD 20
  • Specific Time in FSCalendar

    Specific Time in FSCalendar

    Hello, first of all congratulations for your work I have been very helpful and forgive my bad English, I write from Italy :) I wanted to ask you a favor ... I have a problem ... I'm using your calendar to issue a local notification on my iPhone, the problem is that the notification is issued properly on the selected day but at 00:00 I would need that notification is set to a specific time of my choice, I can not find the right spot in your code to be able to get this ...

    In short, the local notification should be out at 9:00 of the selected day on your calendar ... you can help me with this ??

    thanks Fabio

    opened by FabioDev84 19
  • Calendar crashes when minimumDate & maximumDate is set

    Calendar crashes when minimumDate & maximumDate is set

    I am using xcode 8.2 and ios 10.1 .

    *** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UICollectionViewData.m:433 2017-02-02 12:01:42.310 DemoCalendar[788:16847] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xc000000000000716> {length = 2, path = 7 - 0}'

    opened by snamrata007 17
  • Change particular date colour & add events on particular dates .

    Change particular date colour & add events on particular dates .

    Hey congrats for such a beautiful library. I have 2 arrays as - eventDateArray consisting event NSDates & another array as colouredDateArray having NSDate's to be coloured. How can I achieve the same ? Please reply.

    opened by gabhisekdev 16
  • Fatal Exception: FSCalendar date out of bounds exception.

    Fatal Exception: FSCalendar date out of bounds exception.

    I'm getting this exception:

    Fatal Exception: FSCalendar date out of bounds exception Target date 2016/10/09 beyond bounds [2016/10/16 - 2016/10/09]

    [FSCalendar scrollToDate] in the case for FSCalendarScopeWeek (line 1261 in my code). It's worth noting that I am using dates that are in the local timezone, so maybe the check is not taking that into consideration.

    Fixed 
    opened by glub 14
  • Unknown class FSCalendar in Interface Builder file.

    Unknown class FSCalendar in Interface Builder file.

    I've been trying to manually install FSCalendar but I've been consistently getting this error when I run the code.

    Unknown class FSCalendar in Interface Builder file. I'm not sure why it cannot find the FSCalendar class. screen shot 2016-04-13 at 11 09 21 pm

    opened by kcockrel 14
  • Current date issue

    Current date issue

    Great calendar! Thanks for sharing. There seems to be a bug where the default month is 1 month earlier. You can see this in the demo as well it loads Feb instead of March (current month) and when selecting the date under the settings it goes to wrong month as well.

    opened by tleafs 13
  • Added feature to set the font of the selected day in calendar

    Added feature to set the font of the selected day in calendar

    안녕하세요. 여전히 좋은 라이브러리를 유지보수 해주셔서 감사합니다. 나는 FSCalender 라이브러리를 사용하던 도중에 프로젝트에서 내가 사용하는 기능이 없어서 직접 만들어 보았다. 이것보다 더 좋은 코드가 있다면 그것으로 기능 추가하는게 좋아보인다.

    Hello :) Thank you for maintaining the good library FSCalendar. when I use FSCalendar, I can't find a feature I want in this library. so I made this feature for my project and FSCalendar !

    If there is better code than this code, it would be nice to add functionality to it.

    opened by JacksonJang 0
  • Add week numbers to month view

    Add week numbers to month view

    I have seen several threads regarding week numbers in the month view. So it will be possible to see the week number (1-52) to the left of each week in the month view like below:

    Skærmbillede 2022-12-28 kl  23 09 17

    But it's not described in any of the comments if this is possible or not, and if it is, then how to enable it. So i guess this is not currently supported.

    In Denmark we very much use these week numbers for vacations etc., so it's a valuable thing to be able to present to the users.

    Here are a couple of threads I have read:

    https://github.com/WenchaoD/FSCalendar/issues/117 https://github.com/WenchaoD/FSCalendar/issues/1059

    opened by frigsfrogs 0
  • How to check previous and next month is available or not?

    How to check previous and next month is available or not?

    The following informations are requested in a bug report

    • How to check previous and next month is available or not while tap on prev and next button? Is there any way or property to identify the previous or next month available or not?
    • cocoapods
    • iPhone 7 Plus iOS 15.0
    • Xcode 13.4.1
    • FSCalendar version: 2.8.4
    • Does this happen in the demo project? No
    opened by Nik20112 0
  • Remove Space between cells

    Remove Space between cells

    The following informations are requested in a bug report

    • Want to integrate for remove the space between cells spacing and line spacing. Could you please help on this? Please find the attached screen shot.
    • cocoapods
    • iPhone 7plus iOS14.0
    • Xcode 13.4.1
    • FSCalendar version: 2.8.4

    IMG_B6E63EEFC053-1

    opened by Nik20112 2
  • Adjust the Label inside FSCalendar Dates below.

    Adjust the Label inside FSCalendar Dates below.

    After added below code its display list of UILabel below FSCalendar dates.

     func calendar(_ calendar: FSCalendar, willDisplay cell: FSCalendarCell, for date: Date, at monthPosition: FSCalendarMonthPosition) {
                let labelMy2 = UILabel(frame: CGRect(x: 10, y: 40, width: cell.bounds.width - 20, height: 20))
                labelMy2.font = UIFont.init(font: Font.interRegular, size: 10)
                labelMy2.text = " 00.00 "
                labelMy2.layer.cornerRadius = 2
                labelMy2.backgroundColor = UIColor.init(named: ColorPalette.gray200Color)
                labelMy2.textColor = UIColor.init(named: ColorPalette.gray600Color)
                cell.addSubview(labelMy2)
        }
    

    The label not adjusted, inside calendar properly How to adjust the label properly with reject to the dates.

    Attached issue Images below

    Weekly CFCalendarIssue

    Monthly MonthlyError

    opened by arishanapalli 1
Releases(2.8.3)
Owner
Wenchao Ding
"Never memorize what you can look up in books." - Albert Einstein ( https://en.wikiquote.org/wiki/Albert_Einstein )
Wenchao Ding
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
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
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 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 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
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
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