如何更改UIPickerView选择器的颜色 [英] How to change the color of UIPickerView Selector
问题描述
我有一个UIPicker,我想改变选择器的颜色。是否可以更改选择器的颜色?
I am having a UIPicker, I want to change the color of the selector. Is it possible to change the color of the selector?
推荐答案
我想你正在处理iPhone SDK?可能有一些其他框架使用此名称,因此您可以添加标签以包含uikit,cocoa-touch等。
I suppose you're dealing with the iPhone SDK? There may be some other frameworks which uses this name, so maybe you can add your tags to include uikit, cocoa-touch or something.
无论如何,您可以设置<$ UIPickerView实例的c $ c> showsSelectionIndicator 为NO,因此它隐藏了选择器。然后,您可以使用调整后的选择样式创建一个新视图,并将其添加到UIPickerView上方的超级视图。
Anyway, you can set showsSelectionIndicator
of the UIPickerView instance to NO, so it hides the selector. Then you can create a new view with the adjusted selection style, and add it to the superview above the UIPickerView.
// Some sample code, but you can do this in IB if you want to
_pickerView = [[UIPickerView alloc] init];
_pickerView.showsSelectionIndicator = NO;
[_pickerView sizeToFit];
[self.view addSubview:_pickerView];
UIImage *selectorImage = [UIImage imageNamed:@"selectorImage.png"]; // You have to make it strechable, probably
UIView *customSelector = [[UIImageView alloc] initWithImage:selectorImage];
customSelector.frame = CGRectZero; // Whatever rect to match the UIImagePicker
[self.view addSubview:customSelector];
[customSelector release];
攻击UI元素本身需要做更多的工作,而且这也必须正常工作。
Hacking the UI Element itself will take much more work, and this has to work as well.
这篇关于如何更改UIPickerView选择器的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!