An availability calendar implementation for iOS

Overview

NWCalendarView

NWCalendar View is an iOS control that displays a calendar. It is perfect for appointment or availibilty selection. It allows for selection of a single date or a range. It also allows to disable dates that are unavailable.

Sample Usage

@IBOutlet weak var calendarView: NWCalendarView!

override func viewDidLoad() {
  super.viewDidLoad()

  calendarView.layer.borderWidth = 1
  calendarView.layer.borderColor = UIColor.lightGrayColor().CGColor
  calendarView.backgroundColor = UIColor.whiteColor()


  var date = NSDate()
  let newDate = date.dateByAddingTimeInterval(60*60*24*8)
  let newDate2 = date.dateByAddingTimeInterval(60*60*24*9)
  let newDate3 = date.dateByAddingTimeInterval(60*60*24*30)
  calendarView.disabledDates = [newDate, newDate2, newDate3]
  calendarView.selectionRangeLength = 7
  calendarView.maxMonths = 4
  calendarView.delegate = self
  calendarView.createCalendar()
}

Customization

Make sure to call createCalendar() setting your custom options

disable dates

// Takes an array of NSDates
calendarView.disabledDates = [newDate, newDate2, newDate3]

Set Max Months

You may only want to allow going 4 months into the future

calendarView.maxMonths = 4

Set selection Range (defaults to 0)

selectionRangeLength = 7

Delegate

didChangeFromMonthToMonth(fromMonth: NSDateComponents, toMonth: NSDateComponents)

func didChangeFromMonthToMonth(fromMonth: NSDateComponents, toMonth: NSDateComponents) {
  println("Change From month \(fromMonth) to month \(toMonth)")
}

didSelectDate(fromDate: NSDateComponents, toDate: NSDateComponents)

func didSelectDate(fromDate: NSDateComponents, toDate: NSDateComponents) {
  println("Selected date \(fromDate.date!) to date \(toDate.date!)")
}

TODO

  1. Enable going into the past
  2. Dynamic adding of months when scrolling in to past
  3. Make all aspects customizable (font, colors, etc..)
  4. Turn into cocoapod

License

MIT

Comments
  • the wrong day

    the wrong day

    Hello, I downloaded your calendar which is simple and perfect , but there is a problem with the day . For example the 1st of January 2016 is a Friday not a Thursday , there is always the wrong day on the calendar .

    Thanks in advance for your respond

    opened by marcandree 8
  • didSelectDate returning incorrect days

    didSelectDate returning incorrect days

    Dowloaded and ran the demo in the master today, and found that on selecting a date, ViewController.swift line 52:

    print("Selected date (fromDate.date!) to date (toDate.date!)")

    returned incorrect dates. For example, with default settings: clicking Nov 15 would select Nov 15 - Nov 21 on the calendar (coloured red), but the console returns:

    Selected date 2015-11-14 17:00:00 +0000 to date 2015-11-20 17:00:00 +0000

    (GMT +7, I live in Bangkok). Found that NWCalendarMonthContentView.swift line 393, changing:

    day.day -= 1

    into:

    dayView.day!.day += 1 // day.day -= 1

    solves this issue. It now returns the correct selected dates:

    Selected date 2015-11-15 17:00:00 +0000 to date 2015-11-21 17:00:00 +0000

    However, on line 403 (after if notifyDelegate{}) I added:

    dayView.day!.day -= 1

    to prevent selection issues on the calendar.

    opened by ghost 2
  • Probably not an Issue but something i would to to do

    Probably not an Issue but something i would to to do

    Where do i remove the red line that appears when i click on a date? I want to select a date and highlight that date specifically not the entire week and add an event on the date selected. I hope you can help fix this minor solution thanks in advance.

    opened by 0katz 2
  • DayViewHeight adjustment goes wrong

    DayViewHeight adjustment goes wrong

    I found you are adjusting following month views with offset by DayViewHeight in a following code.

      func createMonthViewForMonth(month: NSDateComponents) {
        var overlapOffset:CGFloat = 0
        var lastMonthMaxY:CGFloat = 0
        if monthViews.count > 0 {
          let lastMonthView = monthViews[monthViews.count-1]
          lastMonthMaxY = CGRectGetMaxY(lastMonthView.frame)
    
          if lastMonthView.numberOfWeeks == 6 || monthStartsOnFirstDayOfWeek(month) {
            overlapOffset = dayViewHeight
          } else {
            overlapOffset = dayViewHeight * 2
          }
        }
    }
    

    But this goes wrong in some places like Feb 2026. Because it is having only 4 rows of dates with just 28 days.

    simulator screen shot mar 1 2016 10 15 32 pm

    opened by dinarajas 1
  • FIXED issue with dayViewHeight adjustments for months with 4 weeks

    FIXED issue with dayViewHeight adjustments for months with 4 weeks

    I found you are adjusting following month views with offset by DayViewHeight in a following code.

      func createMonthViewForMonth(month: NSDateComponents) {
        var overlapOffset:CGFloat = 0
        var lastMonthMaxY:CGFloat = 0
        if monthViews.count > 0 {
          let lastMonthView = monthViews[monthViews.count-1]
          lastMonthMaxY = CGRectGetMaxY(lastMonthView.frame)
    
          if lastMonthView.numberOfWeeks == 6 || monthStartsOnFirstDayOfWeek(month) {
            overlapOffset = dayViewHeight
          } else {
            overlapOffset = dayViewHeight * 2
          }
        }
    }
    

    But this goes wrong in some places like Feb 2026. Because it is having only 4 rows of dates with just 28 days.

    simulator screen shot mar 1 2016 10 15 32 pm

    opened by dinarajas 0
  • Day and Date Mismatch when region is changed from device.

    Day and Date Mismatch when region is changed from device.

    When region is change from Setting. Day and date are not showing correctly. For instance, I changed my region to Malaysia then popup calendar is showing that 1st Jan of 2018 is Sunday. Actually 1st Jan of 2018 should be Monday. How can I implement that to be correct?

    opened by WinKhant-JLI 0
  • Frame not set well

    Frame not set well

    untitled-1

    There were no problem with the frame till today. but when i run my application, calander is shown in this way. Dont know the problem behind it. Pls tell.

    opened by mahin8514 0
  • Update Issues

    Update Issues

    Hi, it appears that most of the code has broken down with the switch to Swift 3 / ios 10. Any plans to make a new release? I'm currently working on one but it's not working out (giving me runtime errors, I fixed all the build errors) and I don't know why.

    opened by aparkerryan27 1
Owner
Nicholas Wargnier
Nicholas Wargnier
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
Dead simple calendar implementation

Package provides a CalendarView which can be used to display simple calendar in your App.

Sergei Kononov 4 Oct 7, 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
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
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
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
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
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 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 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 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
Anime Calendar's iOS App - Schedule your seasonal anime to watch!

?? Anime Calendar Anime Calendar's iOS App - Schedule your seasonal anime to watch! Currently in progress UI Uses Xibs and some programmatic views. De

Leonardo 11 Jan 1, 2023
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