前言:本人项目中封装的自定义datePickView,简单、实用。使用UIDatePicker控件,显示年月日,调用代理方法回调选择的时间。
QQ20170830-155705-HD1.gif- 初始化 ZHDatePickerView
ZHDatePickerView *pickerView = [[ZHDatePickerView alloc] initDatePickerWithDefaultDate:nil datePickerMode:UIDatePickerModeDate];
// 改变确定按钮颜色
// pickerView.rightBarColor = [UIColor orangeColor];
// 改变toolBar背景条颜色
// pickerView.toolBarTintColor = [UIColor whiteColor];
pickerView.delegate = self;
[pickerView show];
- 实现代理方法 pickerView: didSelectDateString:
- (void)pickerView:(ZHDatePickerView *)pickerView didSelectDateString:(NSString *)dateString
{
[self.dateButton setTitle:dateString forState:UIControlStateNormal];
}
网友评论