Giter Club home page Giter Club logo

fscalendar's Introduction

fscalendar

Version License Platform

Example

fscalendar1           fscalendar2

Installation

  • Using cocoapods:pod 'FSCalendar'
  • Manually: Drag all .h and .m files in FSCalendar group to your project
#import "FSCalendar.h"

Setup

Use Interface Builder (Recommended)

  1. Drag two UIView objects to ViewController Scene, change the Custom Class to FSCalendarHeader and FSCalendar
    fscalendar-storyboard1
    fscalendar-storyboard2

2. After adjust the position and frame, link `header` property of the calendar to the header, and the `dataSource` and `delegate` to the ViewController
![fscalendar-storyboard3](https://cloud.githubusercontent.com/assets/5186464/6655159/ac02925a-cb2b-11e4-885e-a287ad5c7769.png) 3. Implement `FSCalendarDataSource` and `FSCalendarDelegate` in ViewController.m

Use code

In viewDidLoad (or loadView) of ViewController.m

FSCalendarHeader *header = [[FSCalendarHeader alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[self.view addSubview:header];
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 44, 320, 280)];
calendar.header = header;
calendar.dataSource = self;
calendar.delegate = self;
[self.view addSubview:calendar];
self.calendar = calendar;

Core classes

FSCalendar

@property (weak, nonatomic) IBOutlet id<FSCalendarDelegate> delegate;

A delegate object to handle common user tap/scroll event, see FSCalendarDelegate for details.

@property (weak, nonatomic) IBOutlet id<FSCalendarDataSource> dataSource;

A dataSource object to provide subtitle, event dot or other sources, see FSCalendarDataSource for details.

@property (weak, nonatomic) IBOutlet FSCalendarHeader *header;

An UIView subclass which afford a scrolling effect for month symbol.

@property (assign, nonatomic) FSCalendarFlow flow;

An enumeration value to determine the scroll direction of FSCalendar, default value is FSCalendarFlowHorizontal

@property (assign, nonatomic) BOOL autoAdjustTitleSize;

The text size of FSCalendar is automaticly calculated based on the frame by default. To turn it off, set this value to NO.

@property (copy, nonatomic) NSDate *currentDate;

The current date of calendar, default is [NSDate date];

@property (readonly, nonatomic) NSDate *selectedDate;

Get the selected date of FSCalendar

@property (readonly, nonatomic) NSDate *currentMonth;

Get the current month of FSCalendar.Extract it with NSDateComponents, or currentMonth.fs_month and currentMonth.fs_year

@property (assign, nonatomic) FSCalendarCellStyle cellStyle UI_APPEARANCE_SELECTOR;

The background style for today and selected cell, default is FSCalendarCellStyleCircle.

@property (strong, nonatomic) UIFont   *titleFont UI_APPEARANCE_SELECTOR;

The font for day text. To change the font size, set autoAdjustTitleSize to NO

@property (strong, nonatomic) UIFont   *subtitleFont UI_APPEARANCE_SELECTOR;

The font for subtitle text. To change the font size, set autoAdjustTitleSize to NO

@property (strong, nonatomic) UIFont   *weekdayFont UI_APPEARANCE_SELECTOR;

The font for weekday text. To change the font size, set autoAdjustTitleSize to NO

@property (strong, nonatomic) UIFont   *headerTitleFont UI_APPEARANCE_SELECTOR;

The font for scrolling header text. To change the font size, set autoAdjustTitleSize to NO

@property (strong, nonatomic) UIColor  *eventColor UI_APPEARANCE_SELECTOR;

The color for event dot.

@property (strong, nonatomic) UIColor  *weekdayTextColor UI_APPEARANCE_SELECTOR;

The text color of weekday.

@property (nonatomic) UIColor *titleDefaultColor UI_APPEARANCE_SELECTOR;

The day text color for default state.

@property (nonatomic) UIColor *titleSelectionColor UI_APPEARANCE_SELECTOR;

The day text color for selection state.

@property (nonatomic) UIColor *titleTodayColor UI_APPEARANCE_SELECTOR;

The day text color where the date is equal to currentDate.

@property (nonatomic) UIColor *titlePlaceholderColor UI_APPEARANCE_SELECTOR;

The day text color where the date is not in currentMonth.

@property (nonatomic) UIColor *titleWeekendColor UI_APPEARANCE_SELECTOR;

The day text color where the date is weekend.

@property (nonatomic) UIColor *subtitleDefaultColor UI_APPEARANCE_SELECTOR;

The subtitle text color for default state.

@property (nonatomic) UIColor *subtitleSelectionColor UI_APPEARANCE_SELECTOR;

The subtitle text color for selection state.

@property (nonatomic) UIColor *subtitleTodayColor UI_APPEARANCE_SELECTOR;

The subtitle text color where the date is equal to currentDate.

@property (nonatomic) UIColor *subtitlePlaceholderColor UI_APPEARANCE_SELECTOR;

The subtitle text color where the date is not in currentMonth.

@property (nonatomic) UIColor *subtitleWeekendColor UI_APPEARANCE_SELECTOR;

The subtitle text color where the date is weekend.

@property (nonatomic) UIColor *selectionColor UI_APPEARANCE_SELECTOR;

The cell background color for selection state.

@property (nonatomic) UIColor *todayColor UI_APPEARANCE_SELECTOR;

The cell background color where the date is equal to currentDate.

@property (nonatomic) UIColor  *headerTitleColor UI_APPEARANCE_SELECTOR;

The text color for FSCalendarHeader.

@property (nonatomic) NSString *headerDateFormat UI_APPEARANCE_SELECTOR;

The date format for FSCalendarHeader.

FSCalendarDataSource

- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date;

To provide a subtitle right below the day digit.

- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date;

To provide an event dot below the day cell.

FSCalendarDelegate

- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date;

To determine whether the day cell should be selected and show the selection layer.

- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date;

This method would execute after a cell is managed to be selected and show the selection layer.

- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar;

This method would execute when calendar month page is changed.

Requirements

ios 7.0

Known issues

  1. The title size changed as we change frame size of FSCalendar: Automatically adjusting font size based on frame size is default behavior of FSCalendadr, to disable it:
self.calendar.autoAdjustTitleSize = NO; 
self.calendar.titleFont = otherTitleFont;
self.calendar.subtitleFont = otherSubtitleFont;

titleFont and subtitleFont is also available for UIAppearance selector, but would not take any effect if autoAdjustTitleSize value is YES

Author

Wenchao Ding, [email protected]

License

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

Others

  • If FSCalendar cannot meet your requirment, welcome to submit issues or pull request
  • If you are using this library and using custom color modulation, please take a screenshot for your calendar appearance here, this will help others better matching color in their apps, thanks

fscalendar's People

Contributors

wenchaod avatar

Watchers

James Cloos avatar ed1son avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.