修改UIDatePicker选择指示器的颜色 [英] Modify UIDatePicker selection indicator tint color
问题描述
是否可以修改 UIDatePicker
的选择指示器的颜色?还是可以删除它,以便我可以添加自己的选择指示符图像?
Is it possible to modify the tint color of a UIDatePicker
's selection indicator? Or can it be removed so I can add my own selection indicator image?
在 UIPickerView
的情况下我知道您可以禁用选择指示器,以便提供自己的选择指示器图像。
I know in the case of UIPickerView
´s you can disable the selection indicator so that you can provide your own selection indicator image.
推荐答案
没有可供更改的选项默认情况下,选择指示器的颜色。
不过,您可以采取解决方法。我将添加一个简单的 UIView
,该颜色具有您选择的颜色和透明度的alpha值。 Se的大小和坐标相应于原始选择指示器以覆盖它(大小为280x44,标准选择器的坐标为20/130-不确定,因此请找出正确的值,以防它们不匹配)。
There is no option to change the color of selection indicator by default.
You can make a workaround though. I would add a simple UIView
with a color of your choice and alpha value for transparency. Se the size and coordinates accordingly to the original selection indicator to overlay it (size 280x44, coordinates 20/130 for standard picker - not sure about that so find out the right values in case these don't match).
UIView *overlayIndicator = [[UIView alloc] initWithFrame:CGRectMake(20, 130, 280, 44)];
overlayIndicator.backgroundColor = [UIColor redColor];
overlayIndicator.alpha = 0.5f;
[yourDatePicker addSubview:overlayIndicator];
希望您可以从这里开始。
Hope it's something you can start with.
这篇关于修改UIDatePicker选择指示器的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!