且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更改UIPickerView选择指示器的颜色

更新时间:2023-12-04 12:26:16

我能提供的***解决方案是将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       
}

亲切的问候