更改UIPickerView选择指示器的颜色 [英] Change colour of UIPickerView selection indicators

查看:141
本文介绍了更改UIPickerView选择指示器的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的UIPickerView的背景很暗,很难看清选择线.无论如何,可以将它们更改为我选择的颜色吗?

Our UIPickerView has a dark background and the selection lines are incredibly hard to see. Is there anyway to change them to a colour of my choosing?

更新:我正在谈论熊猫"项目上方和下方的---.

Update: I'm talking about the --- above and below the "Panda" item.

    Cat
    Dog
  Elephant
-----------
   Panda
-----------
   Bear
  Giraffe

推荐答案

我能提供的最佳解决方案是将2个UIImage放置在拾取轮的顶部,宽度为1,长度设置为您的首选项.这就是我克服这个问题的方式.

The best solution I can offer is to place 2 UIImages on top of your picker wheel at the width of 1 and length set to your preference. This is how I overcame this.

如果您需要多个尺寸视图,则效果不佳,因此以编程方式执行此操作以适应您的尺寸更改将是次佳解决方案.要使用if语句以编程方式更改大小,请执行以下操作:

It does not work well if you require multiple size views so programatically doing it to cater for your size changes would be the next best solution. To programatically change the size using if statements:

如何在iPhone中的Objective-c

如果您根据方向更改尺寸,请添加一个if语句来处理方向,如下所示:

If you change the size based on orientation add an if statement that handles orientation like so:

 if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
     // code for landscape orientation      
}
if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
     // code for Portrait orientation       
}

亲切的问候

这篇关于更改UIPickerView选择指示器的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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