Skip to content
piggybear edited this page Dec 28, 2018 · 9 revisions

Swift使用

查看使用文档

CocoaPods安装

pod 'PGDatePicker'

使用

引入头文件

#import <PGDatePick/PGDatePickManager.h>
PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
PGDatePicker *datePicker = datePickManager.datePicker;
datePicker.delegate = self;
[self presentViewController:datePickManager animated:false completion:nil];

#pragma PGDatePickerDelegate
- (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents {
NSLog(@"dateComponents = %@", dateComponents);
}

如果不设置minimumDatemaximumDate默认是无穷小和无穷大

语言跟着手机系统语言走,默认有英文,中文,繁体中文,如果是模拟器的话,将模拟器的系统语言改成中文即显示中文

设置弧度(目前还是不太好,待优化)

datePicker.isHiddenWheels = false;

设置循环滚动

datePicker.isCycleScroll = true;

设置时分间隔

//分间隔 默认时1
@property (nonatomic) NSInteger minuteInterval;
//秒间隔 默认时1
@property (nonatomic) NSInteger secondInterval;

设置样式

//设置线条的颜色
datePicker.lineBackgroundColor = [UIColor redColor];
//设置选中行的字体颜色
datePicker.textColorOfSelectedRow = [UIColor redColor];
//设置未选中行的字体颜色
datePicker.textColorOfOtherRow = [UIColor blackColor];

//设置取消按钮的字体颜色
datePicker.cancelButtonTextColor = [UIColor blackColor];
//设置取消按钮的字
datePicker.cancelButtonText = @"取消";
//设置取消按钮的字体大小
datePicker.cancelButtonFont = [UIFont boldSystemFontOfSize:17];

//设置确定按钮的字体颜色
datePicker.confirmButtonTextColor = [UIColor redColor];
//设置确定按钮的字
datePicker.confirmButtonText = @"确定";
//设置确定按钮的字体大小
datePicker.confirmButtonFont = [UIFont boldSystemFontOfSize:17];
Clone this wiki locally