CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✓ | 
| LangLanguage | SwiftSwift | 
| License | MIT | 
| ReleasedLast Release | Feb 2016 | 
| SPMSupports SPM | ✗ | 
Maintained by Nate Armstrong, Nate Armstrong.
To run the example project, clone the repo, and run pod install from the CalendarViewDemo directory first.
CalendarView is available through Carthage and CocoaPods. To install it, simply add the following line to your Podfile:
pod "CalendarView"Use the CalendarView class in code:
let calendar = CalendarView(frame: CGRectMake(0, 0, CGRectGetWidth(view.frame), 320))
view.addSubview(calendar)or as an outlet (supports auto layout)
@IBOutlet weak var calendar: CalendarView!The selected date is the current date by default. You can select any date by using the selectDate(date: Moment) method.
let date: NSDate = MY_NSDATE
calendar.selectDate(moment(date))A CalendarView’s delegate is notified of two events:
calendarDidSelectDate(date: Moment) // called when user taps a date
calendarDidPageToDate(date: Moment) // called when users swipes monthThe CalendarView class uses SwiftMoment for date manipulation.
extension ViewController: CalendarViewDelegate {
  func calendarDidSelectDate(date: Moment) {
    title = date.format(dateFormat: "MMMM d, yyyy")
  }
  func calendarDidPageToDate(date: Moment) {
    title = date.format(dateFormat: "MMMM d, yyyy")
  }
}The aim is to allow the calendar to be as customizable as possible without making it overly complex and bloated.
You can customize the look of the calendar by setting certain class properties of CalendarView.
import UIKit
import CalendarView
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  var window: UIWindow?
  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Calendar appearance
    CalendarView.daySelectedBackgroundColor = UIColor.secondaryColor()
    CalendarView.daySelectedTextColor = UIColor.whiteColor()
    CalendarView.todayBackgroundColor = UIColor(white: 0.0, alpha: 0.3)
    CalendarView.todayTextColor = UIColor.whiteColor()
    CalendarView.otherMonthBackgroundColor = UIColor.clearColor()
    CalendarView.otherMonthTextColor = UIColor(white: 1.0, alpha: 0.3)
    CalendarView.dayTextColor = UIColor(white: 1.0, alpha: 0.6)
    CalendarView.dayBackgroundColor = UIColor.clearColor()
    CalendarView.weekLabelTextColor = UIColor(white: 1.0, alpha: 0.3)
    return true
  }
}By default the first day of the month is automatically selected when the user swipes to a different month. You can customize this behavior by modifying the selectedDayOnPaged property of your CalendarView instance:
public var selectedDayOnPaged: Int? = 1If set to nil, no day will be automatically selected on swipe.
Nate Armstrong, [email protected]
CalendarView is available under the MIT license. See the LICENSE file for more info.