我有 UIDatePicker,我想在 UIDatePicker 中绘制时间,例如灰色
我需要这个,如果在我的图形中绘制了一些间隔,那么在 datePicker 中用户无法选择这个时间
我有 UIDatePicker,我想在 UIDatePicker 中绘制时间,例如灰色
我需要这个,如果在我的图形中绘制了一些间隔,那么在 datePicker 中用户无法选择这个时间
很抱歉告诉你,但UIDatePicker
不支持像你描述的那样设置有效时间范围。唯一的选项是最小和最大日期。如果你真的需要这个,你需要从头开始构建一个自定义控件,这将花费很多精力。
I think I found my solution, I can draw time to another color
for (UIView *view in datePicker.subviews) {
for (UIView *subView in view.subviews) {
for (UIView *subSubView in subView.subviews) {
for (UIView *thirdSubView in subSubView.subviews) {
for (UILabel *label in thirdSubView.subviews) {
if ([label isKindOfClass:[UILabel class]]) {
label.textColor = [UIColor redColor];
}
}
}
}
}
}
I need to catch event when scrolling DatePicker, I doing this, and this work, but I break the scroll
for (UIView *view in datePicker.subviews) {
for (UIView *subView in view.subviews) {
Class UIPickerTableView = objc_getClass("UIPickerTableView");
if ([subView isKindOfClass:UIPickerTableView]) {
UITableView *sub = (UITableView *) subView;
sub.delegate = self;
}
for (UIView *subSubView in subView.subviews) {
I try doing another way, but it doesn't work
for (UIView *view in datePicker.subviews) {
for (UIView *subView in view.subviews) {
Class UIPickerTableView = objc_getClass("UIPickerTableView");
Method targetMethod = class_getInstanceMethod(UIPickerTableView, @selector(scrollViewDidScroll:));
Method newMethod = class_getInstanceMethod(UIPickerTableView, @selector(__scrollViewDidScroll:));
method_exchangeImplementations(targetMethod, newMethod);
for (UIView *subSubView in subView.subviews) {