MDCalendarSelector
is a lightweight customizable view that allows you to easily select a range of dates.
CocoaPods is a dependency manager for Swift and Objective-C, which automates and simplifies the process of using 3rd-party libraries like MDCalendarSelector
in your projects. Simply add the following lines to your Podfile:
use_frameworks!
pod 'MDCalendarSelector'
Drag the MDCalendarSelector/MDCalendarSelector
folder into your project.
(see sample Xcode project in /Demo
)
Declare and initialize MDCalendarSelector like a normal view. Add an MDCalendarSelectorDelegate to your class to listen to changes to the selected date range.
var calendarSelector = MDCalendarSelector();
calendarSelector.delegate = self;
func calendarSelector(calendarSelector: MDCalendarSelector, startDateChanged startDate: NSDate)
func calendarSelector(calendarSelector: MDCalendarSelector, endDateChanged endDate: NSDate)
MDCalendarSelector
can be customized by editing the following properties:
var backgroundViewColor: UIColor // background color of the calendar, default is UIColor.blackColor()
var highlightedColor: UIColor // background color of header and of selected days, default is UIColor.redThemeColor()
var dateTextColor: UIColor // text color of days that can be selected, default is UIColor.whiteColor()
var nextDateTextColor: UIColor // text color of days that are in a different month, default is UIColor(white: 1.0, alpha: 0.5)
var disabledTextColor: UIColor // text color of days that are disabled, default is UIColor(white: 1.0, alpha: 0.3)
var highlightedTextColor: UIColor // text color of selected days and header month, default is UIColor.whiteColor()
var maxRange: UInt // max amount of days that can be selected, default is 21
var regularFontName: String? // font name for all regular text, default font is the systemFont
var boldFontName: String? // font name for all bold text, default font is the boldSystemFont
var headerFontSize: CGFloat // font size for the headerLabel text, default is 15.0
var dateFontSize: CGFloat // font size for dates, default is 13.0
var startDate: NSDate // initial date of selected range
var endDate: NSDate // last date of selected range
var selectedLength: Int // length of selected date range
func goToToday() // reset selected date to today
MDCalendarSelector
was initially used in an app I created, In the Loop.