How to change the color of UIPickerView Selector(如何更改 UIPickerView 选择器的颜色)
问题描述
我有一个 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 实例的 showsSelectionIndicator
设置为 NO,从而隐藏选择器.然后你就可以创建一个新的视图,调整后的选择样式,并将其添加到 UIPickerView 上方的 superview 中.
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 选择器的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何更改 UIPickerView 选择器的颜色


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01