Ios 更改UIPicker高亮显示的选项卡宽度

Ios 更改UIPicker高亮显示的选项卡宽度,ios,objective-c,ios7,uipicker,Ios,Objective C,Ios7,Uipicker,我正在我的一个项目中使用UIPicker 我有UIPickerView的大小和位置为 58, 264, 204, 216 x y width height 我正在做与iOS 7兼容的应用程序 在iOS 7中,我只想显示204的宽度,但在iOS 6和更早版本中,我想显示300的宽度 因为下面就是我所做的 -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NS

我正在我的一个项目中使用UIPicker

我有UIPickerView的大小和位置为

 58, 264, 204, 216
  x   y  width height
我正在做与iOS 7兼容的应用程序

在iOS 7中,我只想显示204的宽度,但在iOS 6和更早版本中,我想显示300的宽度

因为下面就是我所做的

-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{

    if (IS_DEVICE_RUNNING_IOS_7_AND_ABOVE()) {
    NSLog(@"changing font...");
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 204, 44)]; // your frame, so picker gets "colored"

        label.textColor = [UIColor blackColor];
        label.font = [UIFont fontWithName:localize(@"myFontName") size:14];
        label.textAlignment = NSTextAlignmentCenter;

        label.text = [arrayGender objectAtIndex:row];

        return label;
    } else {
        [pickerView setFrame: CGRectMake(10, 264, 300, 216)];
        pickerView.backgroundColor = [UIColor clearColor];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 260, 44)];

        label.textColor = [UIColor blackColor];
        label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:14];

        label.text = [NSString stringWithFormat:@"%@", [arrayGender objectAtIndex:row]];
        return label;
    }
}
这是完美的工作

问题就在这里。荧光笔大小固定为204(这是IB中为UIPicker设置的大小宽度)

你知道怎么对付这个荧光灯吗

下面是我所说的荧光灯示例

下面是我所说内容的真实图像


看起来您应该创建自己的UIView作为自定义选择指示器。查看详细信息。

我通过颠倒这些东西解决了这个问题

在IB中,我创建了宽度为320的UIPicker视图,并在代码中调整了宽度