Latest 1.0.1
Homepage https://github.com/wanghouwen/HWDatePicker
License MIT
Platforms ios 8.0, requires ARC
Dependencies HWExtension/Category
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

How to use

Import the class header.

#import "HWDatePicker.h"

create date picker view and add to supperview.

CGSize screenSize = [UIScreen mainScreen].bounds.size;

HWDatePicker *datePicker = [[HWDatePicker alloc] initWithFrame:CGRectMake(0, screenSize.height - 300, screenSize.width, 300)];
datePicker.backgroundColor = [UIColor whiteColor];
datePicker.dateFormatter = @"YYYY年/MM月/dd日/HH时/mm分"; // 可不设置,有默认值
datePicker.minimumDate = [NSDate date]; // 可不设置
datePicker.maximumDate = [[NSDate date] dateByAddingTimeInterval:24 * 3600 * 10]; // 可不设置
datePicker.delegate = self; // 可不设置

[self.view addSubview:datePicker];

customize it to your own style.

#pragma mark HWDatePickerDelegate

- (CGFloat)pickerView:(HWDatePicker *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 44;
}

- (NSDictionary *)pickerView:(HWDatePicker *)pickerView textAttributeForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (component == 0) {
        return @{NSForegroundColorAttributeName : [UIColor blueColor], NSFontAttributeName : [UIFont boldSystemFontOfSize:18]};
    } else if (component == 1) {
        return @{NSForegroundColorAttributeName : [UIColor greenColor]};
    } else if (component == 2) {
        return @{NSForegroundColorAttributeName : [UIColor redColor]};
    } else if (component == 3) {
        return @{NSForegroundColorAttributeName : [UIColor orangeColor]};
    } else if (component == 4) {
        return @{NSForegroundColorAttributeName : [UIColor purpleColor]};
    }
    return nil;
}

- (void)pickerViewSelectDateDidChanged:(HWDatePicker *)pickerView newDate:(NSDate *)newDate
{
    NSLog(@"new date : %@", newDate);
}

Requirements

Installation

HWDatePicker is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'HWDatePicker'

Author

wanghouwen, [email protected]

License

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

Latest podspec

{
    "name": "HWDatePicker",
    "version": "1.0.1",
    "summary": "u53efu81eau5b9au4e49u683cu5f0fu7684u65e5u671fu9009u62e9u63a7u4ef6",
    "homepage": "https://github.com/wanghouwen/HWDatePicker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "wanghouwen": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wanghouwen/HWDatePicker.git",
        "tag": "1.0.1"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "HWDatePicker/*.{h,m}",
    "public_header_files": "HWDatePicker/*.h",
    "dependencies": {
        "HWExtension/Category": []
    }
}

Pin It on Pinterest

Share This