2013-10-22 89 views
0

我在我的项目中使用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:(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(这是UIPicker在IB中设置的尺寸宽度)

任何想法如何解决这个荧光笔?

通过荧光笔,下面是示例我的意思。

enter image description here

下面是我所谈论的实际图像。

enter image description here

回答

0

我解决了它通过扭转的东西。

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

0

看起来你应该让自己的UIView作为一个自定义选择指示器。详情请看here

+0

no custom pls ... –