如何更改UIPicker Color?苹果手机 [英] How to change UIPicker Color ? iPhone

查看:90
本文介绍了如何更改UIPicker Color?苹果手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我观察到UIPicker总是保持黑色,

I have observed that UIPicker always remains in black color,

有没有办法改变UIPicker&的颜色。这是选择指标吗?

Is there any way to change the color of UIPicker & it's Selection Indicator?

感谢您的帮助。

推荐答案

我假设您要更改的是选择器边框的颜色,而不是用户与之交互的中心区域的颜色。在这种情况下,请执行以下操作:

I assume all you want to change is the color of the border of the picker, not of the region in the center with which the user interacts. In this case, do the following:

创建4个封面UIViews并将它们直接添加到UIPicker,如:

Create 4 "cover" UIViews and add them directly to the UIPicker, as in:

[picker addSubview: coverView];

将这些视图放在选取器边框的顶部,底部,左侧和右侧。 (您需要尝试使用尺寸。)将coverViews的backgroundColor设置为您想要的颜色,并调整alpha以从拾取器获取渐变阴影。同样,这可能需要一些实验。

Position these views over the top, bottom, left and right sides of the picker border. (You will need to experiment with sizes.) Set the backgroundColor of the coverViews to the color you want, and adjust the alpha to get the gradient shading from the picker. Again, this may take a bit of experimentation.

另一种方法是创建一个覆盖整个选择器的大覆盖视图,并覆盖 - (UIView *)hitTest: (CGPoint)指向withEvent:(UIEvent *)事件方法,以便您的封面视图不会拦截针对选择器的触摸。

The alternative would be to create one big coverView that covers the entire picker, and override the - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event method so that your cover view did not intercept the touches meant for the picker.

这篇关于如何更改UIPicker Color?苹果手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆