OCCalendar-Ext 0.1.8

OCCalendar-Ext 0.1.8

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2014年12月

Kjuly 保持维护。



  • Kaijie Yu

OCCalendarController

简介

OCCalendar 是一个用于 iPhone/iPad 的非常简单的组件,它提供了一个 "Popover" 日期选择器控制器。将其添加到您的项目中非常简单,并且是 100% CoreGraphics 代码,因此不使用任何图像,并且是分辨率无关的。我意识到我需要进一步减小iPhone的大小。我最初只为 iPad 编写它,我的路径和尺寸都稍微宽了一点。我会在我有空的时候修它。

Screenshot

许可证

OCCalendar 以 BSD 许可证获得授权,可用于带或不带归属。祝你玩得开心!

用法

将以下文件拖入您的项目

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

然后在您希望调用的类中实现 OCCalendarDelegate 协议。此协议中的唯一方法指定了日历向应用程序报告日期的开始和结束范围的方式。这些范围可作为 NSDate 对象返回,方便使用。在演示应用程序中,我们执行以下操作

 - (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;
} 

现在,您应该能够通过 alloc'ing 和 init'ing 它,然后将其添加到视图中来显示日历。

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

自定义

您可以通过调整 CoreGraphics 渲染代码来自定义控制器的外观和感觉。我意识到这目前看起来不是很漂亮,但我会最终重构它以确保它是整洁的。您可以通过在初始化器中更改 "arrowPosition" 枚举来将小箭头放置在 Popover 的右侧或左侧。

[[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