iOS 日期選擇:PDTSimpleCalendar

ynnc 9年前發布 | 21K 次閱讀 iOS開發 移動開發 PDTSimpleCalendar

PDTSimpleCalendar 是通過 UICollectionView 實現的 iOS 簡單日歷/日期選擇器。

iOS 日期選擇:PDTSimpleCalendar iOS 日期選擇:PDTSimpleCalendar

Upgrade Note

You should read the Release Notes when you upgrade to a newer version.

Install

Cocoapods

in yourPodfilejust add:

pod 'PDTSimpleCalendar', '~> 0.8.0'

then runpod install

And finally in your project import#import <PDTSimpleCalendar/PDTSimpleCalendar.h>

Carthage

In yourCartfilesimply add:

github "jivesoftware/PDTSimpleCalendar" ~> 0.8.0

runcarthage update

Finally you need to add the built framework to your project. For more information about Carthage : github.com/Carthage/Carthage

Warning: Carthage uses dynamic framework and will only work if your app targets iOS 8.0 or later.

Old-School

If you don't like cocoapods or Carthage or Cocoapods-Rome, you can still import it usinggit submoduleor simply copy/paste all the source files inPDTSimpleCalendarto your project.

Customize it

Calendar

  • firstDate: When the calendar must starts. If you don't specify anything, it will default to the first day of the current month (based on[NSDate date]).
  • lastDate: When the calendar must ends. If you don't specify anything, it will default to the last day of the next year (based onfirstDate).
  • calendar: Which calendar to use for display and date calculations. You can set any calendar supported byNSCalendar. the default value will be[NSCalendar currentCalendar].

New in 0.6: if you specify a 'firstDate' and/or 'lastDate' the calendar will display the full month, but dates < firstDate or > lastDate will be disabled. You can see this behavior in the demo app.

Colors

You can change the display of the calendar usingbackgroundColor&overlayTextColorproperties onPDTSimpleCalendarViewController.

Other colors can be set using UIAppearance onPDTSimpleCalendarViewCell&PDTSimpleCalendarViewHeader

[[PDTSimpleCalendarViewCell appearance] setCircleDefaultColor:[UIColor whiteColor]];
[[PDTSimpleCalendarViewCell appearance] setCircleSelectedColor:[UIColor orangeColor]];
[[PDTSimpleCalendarViewCell appearance] setCircleTodayColor:[UIColor blueColor]];
[[PDTSimpleCalendarViewCell appearance] setTextDefaultColor:[UIColor redColor]];
[[PDTSimpleCalendarViewCell appearance] setTextSelectedColor:[UIColor purpleColor]];
[[PDTSimpleCalendarViewCell appearance] setTextTodayColor:[UIColor magentaColor]];
[[PDTSimpleCalendarViewCell appearance] setTextDisabledColor:[UIColor yellowColor]];

[[PDTSimpleCalendarViewHeader appearance] setTextColor:[UIColor redColor]];
[[PDTSimpleCalendarViewHeader appearance] setSeparatorColor:[UIColor orangeColor]];

Here is how it looks in the Producteev app:

Producteev

項目主頁:http://www.baiduhome.net/lib/view/home/1438093425628

 本文由用戶 ynnc 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!