Giter Club home page Giter Club logo

occalendar's Introduction

#OCCalendarController#

##Introduction##

OCCalendar is a very simple component for iPhone/iPad that provides a "Popover" date picker controller. It is very easy to add to your project, and is 100% CoreGraphics code, so it uses no images, and is resolution independent. I realize that I need to cut down the size for iPhone a bit more. I originally wrote it just for iPad, and my paths and sizing are all just slightly too wide for the iPhone. I'll fix it when I get a chance.

Screenshot

##License##

OCCalendar is granted under the BSD license, for use with or without attribution. Have fun!

##Usage##

Drag the following files into your project:

  • OCCalendarViewController.h
  • OCCalendarViewController.m
  • OCCalendarView.h
  • OCCalendarView.m
  • OCSelectionView.h
  • OCSelectionView.m
  • OCDaysView.h
  • OCDaysView.m

Then implement the OCCalendarDelegate protocol in the class you wish to call from. The only method in this protocol specifies a way for the calendar to report back the beginning and ending ranges of dates. These are returnes as NSDate objects for convenience. In the demo app, we do the following:

 - (void)completedWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate {
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateStyle:NSDateFormatterShortStyle];
    
    [self showToolTip:[NSString stringWithFormat:@"%@ - %@", [df stringFromDate:startDate], [df stringFromDate:endDate]]];
    
    calVC.delegate = nil;
    [calVC release];
    calVC = nil;
} 

Now, you should be able to show the calendar by alloc'ing and init'ing it, then adding to your view.

//Here's where the magic happens
    calVC = [[OCCalendarViewController alloc] initAtPoint:CGPointMake(150, 50) inView:self.view];
    calVC.delegate = self;
    [self.view addSubview:calVC.view]; 

##Customization## You can customize the look and feel of the controller by tweaking the CoreGraphics rendering code. I realize that this is not very pretty at the moment, but I'll eventually refactor it to make sure it's all neat and tidy. You can change the placement of the little arrow to either the right or left side of the popover by changing the "arrowPosition" enum in the initializer.

[[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionRight] //Right position
[[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionCenter] //Center position
[[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionLeft] //Left position

occalendar's People

Contributors

crayment avatar markrickert avatar ocrickard avatar

Stargazers

 avatar

Watchers

 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.