iOS 9.2 UIDatePicker组件当前选中的组件行文本颜色未改变
iOS 9.2 UIDatePicker component currently selected component row's text color not changed
我无法更改每个组件行的字体大小和当前选择的UIDatePicker组件行的文本颜色。
在 ViewDidLoad 中,我的代码是:
self.dPicker.backgroundColor = [UIColor grayColor];
[self.dPicker setValue:[UIColor whiteColor] forKey:@"textColor"];
是不是被苹果限制了?
根据Apple's UIKit User Interface Catalog,我们不能自定义日期选择器。
我建议您查看 Whosebug 的其他答案,以了解建议做出 a fake UIDatePicker using UIPickerView and customizing that.
的类似问题
APIUIDatePicker
的外观没有任何变化
然后如果你想这样做,你可以使用 swift:
查看此内容以了解 UIDatePicker
的自定义实施
https://github.com/prolificinteractive/PIDatePicker
如果要更改所选行的颜色,则需要更改行颜色的字体颜色或选择指示符
UIView *abc = [[UIView alloc] initWithFrame:CGRectMake(20, 130, 280, 44)];
abc.backgroundColor = [UIColor redColor];
abc.alpha = 0.5f;
[yourDatePicker addSubview: abc];
试试这个颜色:
yourDatePicker.backgroundColor = UIColor.redColor()
yourDatePicker.setValue(UIColor.blueColor(), forKeyPath: "textColor")
yourDatePicker.setValue(0.8, forKeyPath: "alpha")
@jamshed 您不需要创建子视图并将其添加到 UIDatePicker。
如果你想改变 UIDatePicker 的高亮文本颜色,你可以使用这个代码:
[self.datePicker setValue:@(false) forKey:@"highlightsToday"];
我无法更改每个组件行的字体大小和当前选择的UIDatePicker组件行的文本颜色。
在 ViewDidLoad 中,我的代码是:
self.dPicker.backgroundColor = [UIColor grayColor];
[self.dPicker setValue:[UIColor whiteColor] forKey:@"textColor"];
是不是被苹果限制了?
根据Apple's UIKit User Interface Catalog,我们不能自定义日期选择器。
我建议您查看 Whosebug 的其他答案,以了解建议做出 a fake UIDatePicker using UIPickerView and customizing that.
的类似问题APIUIDatePicker
然后如果你想这样做,你可以使用 swift:
查看此内容以了解 UIDatePicker
https://github.com/prolificinteractive/PIDatePicker
如果要更改所选行的颜色,则需要更改行颜色的字体颜色或选择指示符
UIView *abc = [[UIView alloc] initWithFrame:CGRectMake(20, 130, 280, 44)];
abc.backgroundColor = [UIColor redColor];
abc.alpha = 0.5f;
[yourDatePicker addSubview: abc];
试试这个颜色:
yourDatePicker.backgroundColor = UIColor.redColor()
yourDatePicker.setValue(UIColor.blueColor(), forKeyPath: "textColor")
yourDatePicker.setValue(0.8, forKeyPath: "alpha")
@jamshed 您不需要创建子视图并将其添加到 UIDatePicker。 如果你想改变 UIDatePicker 的高亮文本颜色,你可以使用这个代码:
[self.datePicker setValue:@(false) forKey:@"highlightsToday"];