Latest0.1.3
Homepagehttps://github.com/XHJCoder/XHDatePicker
LicenseMIT
Platformsios 8.0
FrameworksUIKit
Authors

XHDatePicker 日期选择器

日期选择器

Version【版本】

v0.1.3

Installation【安装】

在Podfile文件中添加pod 'XHDatePicker' ,并运行 pod install

Usage【使用】

  • 导入

    #import "XHDatePicker.h"
  • 生成对象并展示
    
    /**
    @param completeBlock 时间选择好之后的回调,返回选择的时间和时间的String值
    */
  • (instancetype)showWithCompleteBlock:(void(^)(NSDate date, NSString dateString))completeBlock;

  • 设置日期选择器样式
    
    typedef enum {
    XHDatePickerModeYearMonthDayHourMinute  = 0,   // 年月日时分
    XHDatePickerModeMonthDayHourMinute,            // 月日时分
    XHDatePickerModeYearMonthDay,                  // 年月日
    XHDatePickerModeYearMonth,                     // 年月
    XHDatePickerModeMonthDay,                      // 月日
    XHDatePickerModeHourMinute                     // 时分
    } XHDatePickerMode;

// default is XHDatePickerModeYearMonthDayHourMinute
@property (nonatomic, assign) XHDatePickerMode datePickerMode;


- 设置最大最小时间限制

@property (nonatomic, strong) NSDate minimumDate; // 限制最大时间(default is nil)
@property (nonatomic, strong) NSDate
maximumDate; // 限制最小时间(default is nil)


- 设置当前显示时间

@property (nonatomic, strong) NSDate *date; // 当前显示时间(default is [NSDate date])


- 设置主题色

@property (nonatomic, strong) UIColor *themeColor;


- 设置时间格式(体现在completeBlock返回的dateString上)

/**

  • 默认与datePickerMode相对应
  • 比如:XHDatePickerModeYearMonthDayHourMinute对应的dateFormatter是:@"yyyy-MM-dd HH:mm"
  • 你也可以设置格式为 yyyy年MM月dd日HH时mm分
    /
    @property (nonatomic, copy) NSString
    dateFormatter;

Example【示例】

    XHDatePicker *datePicker = [XHDatePicker showWithCompleteBlock:^(NSDate *date, NSString *dateString) {
        NSLog(@"%@ , %@",date, dateString);
    }];

    datePicker.date = [NSDate date:@"2018-05-13 22:55" WithFormat:@"yyyy-MM-dd HH:mm"];
    datePicker.minimumDate = [NSDate date:@"2015-01-14 12:14" WithFormat:@"yyyy-MM-dd HH:mm"];
    datePicker.maximumDate = [NSDate date:@"2022-11-23 07:55" WithFormat:@"yyyy-MM-dd HH:mm"];
    datePicker.themeColor = [UIColor redColor];
    datePicker.dateFormatter = @"yyyy年MM月dd日 HH:mm";
    datePicker.datePickerMode = XHDatePickerModeYearMonthDayHourMinute;    

Latest podspec

{
    "name": "XHDatePicker",
    "version": "0.1.3",
    "summary": "u65e5u671fu9009u62e9u5668 for iOS.",
    "homepage": "https://github.com/XHJCoder/XHDatePicker",
    "license": "MIT",
    "authors": {
        "XH_J": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/XHJCoder/XHDatePicker.git",
        "tag": "0.1.3"
    },
    "source_files": [
        "XHDatePicker",
        "XHDatePicker/**/*.{h,m,xib}"
    ],
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This