GithubHelp home page GithubHelp logo

ariffsetiawan / fscalendar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wenchaod/fscalendar

0.0 3.0 0.0 721 KB

An extreme marvelous、beautiful calendar control

Home Page: https://www.cocoacontrols.com/controls/fscalendar

License: MIT License

Objective-C 84.65% C 13.26% Ruby 0.43% Swift 1.67%

fscalendar's Introduction

fscalendar

Version License Platform Carthage compatible

fscalendar---takealook fscalendar-takealoot-weekmode

Installation

Cocoapods:

  • For iOS8+: 👍
use_frameworks!
pod 'FSCalendar'
  • For iOS7+:
pod 'FSCalendar'

Carthage:

  • For iOS8+
github "WenchaoIOS/FSCalendar"

Manually:

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

Support IBInspectable / IBDesignable

Only the methods marked "👍" support IBInspectable / IBDesignable feature. Have fun with Interface builder

Setup

Use Interface Builder (Recommended)

  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

  1. Finally, you should implement FSCalendarDataSource and FSCalendarDelegate in ViewController.m

Or use code

@property (weak , nonatomic) FSCalendar *calendar;
// In loadView 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

private 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

More usage

If you want FSCalendar to scroll vertically

  • Objective - c
_calendar.scrollDirection = FSCalendarScrollDirectionVertical;
  • Swift
calendar.scrollDirection = .Vertical 

fscalendar-vertical

If you want FSCalendar to scroll horizontally (Default)

  • Objective - c
_calendar.scrollDirection = FSCalendarScrollDirectionHorizontal; // By default
  • Swift
calendar.scrollDirection = .Horizontal 

fscalendar-horizontal

For week mode

  • Objective - c
_calendar.scope = FSCalendarScopeWeek;
  • Swift
calendar.scope = .Week 

For month mode

  • Objective - c
_calendar.scope = FSCalendarScopeMonth; // By default
  • Swift
calendar.scope = .Month 

fscalendarscope

To select more than one date

_calendar.allowsMultipleSelection = YES;

fscalendar-mulipleselection

If you want FSCalendar to use Monday as the first column (or any other weekday)

_calendar.firstWeekday = 2; 

fscalendar---monday

The date format of header can be customized

_calendar.appearance.headerDateFormat = @"MMM yy";

fscalendar---headerformat

You can define the appearance

_calendar.appearance.weekdayTextColor = [UIColor redColor];
_calendar.appearance.headerTitleColor = [UIColor redColor];
_calendar.appearance.eventColor = [UIColor greenColor];
_calendar.appearance.selectionColor = [UIColor blueColor];
_calendar.appearance.todayColor = [UIColor orangeColor];
_calendar.appearance.todaySelectionColor = [UIColor blackColor];

fscalendar---colors

The day shape doesn't have to be a circle

  • Objective - c
_calendar.appearance.cellStyle = FSCalendarCellStyleRectangle;
  • Swift
calendar.appearance.cellStyle = .Rectangle

fscalendar---rectangle

FSCalendar can show subtitle for each day

  • Objective - c
// FSCalendarDataSource
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date
{
    return yourSubtitle;
}
  • Swift
// FSCalendarDataSource
func calendar(calendar: FSCalendar!, subtitleForDate date: NSDate!) -> String! {
    return yourSubtitle
}

fscalendar---subtitle2
fscalendar---subtitle1

And event dot for some days

  • Objective - c
// FSCalendarDataSource
- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date
{
    return shouldShowEventDot;
}
  • Swift
// FSCalendarDataSource
func calendar(calendar: FSCalendar!, hasEventForDate date: NSDate!) -> Bool {
    return shouldShowEventDot
}

Or image for some days

  • Objective - c
// FSCalendarDataSource
- (UIImage *)calendar:(FSCalendar *)calendar imageForDate:(NSDate *)date
{
    return anyImage;
}
  • Swift
// FSCalendarDataSource
func calendar(calendar: FSCalendar!, imageForDate date: NSDate!) -> UIImage! {
    return anyImage
}

fscalendar---image

There are left and right boundaries

// FSCalendarDataSource
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
{
    return yourMinimumDate;
}

- (NSDate *)maximumDateForCalendar:(FSCalendar *)calendar
{
    return yourMaximumDate;
}

You can do something when a date is selected

  • Objective - c
// FSCalendarDelegate
- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
{
    // Do something
}
  • Swift
// FSCalendarDelegate
func calendar(calendar: FSCalendar!, didSelectDate date: NSDate!) {
    
}

You can prevent it from being selected

  • Objective - c
// FSCalendarDelegate
- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date
{
    if ([dateShouldNotBeSelected]) {
        return NO;
    }
    return YES;
}
  • Swift
func calendar(calendar: FSCalendar!, shouldSelectDate date: NSDate!) -> Bool {
    if dateShouldNotBeSelected {
        return false
    }
    return true
}

You will get notified when FSCalendar changes the month

  • Objective - c
- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar
{
    // Do something
}
  • Swift
func calendarCurrentMonthDidChange(calendar: FSCalendar!) {
    // Do something
}

FSCalendar can be used on iPad.

fscalendar-ipad

Roll with Interface Builder

fscalendar - ibdesignable

  • fakeSubtitles and fakedSelectedDay is only used for preview in Interface Builder

Known issues

  • 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:
_calendar.appearance.autoAdjustTitleSize = NO; 
_calendar.appearance.titleFont = otherTitleFont;
_calendar.appearance.subtitleFont = otherSubtitleFont;

titleFont and subtitleFont would not take any effect if autoAdjustTitleSize value is YES

  • What if I don't need the today circle?
_calendar.appearance.todayColor = [UIColor clearColor];
_calendar.appearance.titleTodayColor = _calendar.appearance.titleDefaultColor;
_calendar.appearance.subtitleTodayColor = _calendar.appearance.subtitleDefaultColor;
  • Can we hide this? fscalendar---headeralpha
_calendar.appearance.headerMinimumDissolvedAlpha = 0.0;

License

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

Support

  • If FSCalendar cannot meet your requirment, tell me in issues or send your pull requests
  • If you like this control and use it in your app, submit your app's link address here.It would be a great support.

Contact

Donate

fscalendar's People

Contributors

wenchaod avatar jklp avatar zjmdp avatar

Watchers

James Cloos avatar Arif Setiawan avatar  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.