Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何设置UIPickerView选择指示器的样式?_Ios_Objective C_Uipickerview - Fatal编程技术网

Ios 如何设置UIPickerView选择指示器的样式?

Ios 如何设置UIPickerView选择指示器的样式?,ios,objective-c,uipickerview,Ios,Objective C,Uipickerview,我希望实现选择指示器的样式,如下图所示:- 下面是我的代码:- - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel* tView = (UILabel*)view; if (!tView) { tView = [[U

我希望实现选择指示器的样式,如下图所示:-

下面是我的代码:-

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UILabel* tView = (UILabel*)view;
    if (!tView)
    {
        tView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, pickerView.frame.size.width, pickerView.frame.size.height)];
        [tView setFont:[UIFont fontWithName:APP_FONT_OPENSANS_LIGHT size:18]];
        [tView setTextColor:[UIColor colorWithRed:65.0f/255.0f green:65.0f/255.0f blue:65.0f/255.0f alpha:1]];
        [tView setTextAlignment:NSTextAlignmentCenter];
        tView.numberOfLines=1;
    }
    // Fill the label text here
    tView.text=@"Hello Moto";
//    pickerView.subviews[1].backgroundColor = [UIColor whiteColor];
//    pickerView.subviews[2].backgroundColor = [UIColor whiteColor];

    return tView;
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{

    UILabel *labelSelected = (UILabel*)[pickerView viewForRow:row forComponent:component];
    labelSelected.layer.cornerRadius = 20.0f;
    [labelSelected setBackgroundColor:[UIColor whiteColor]];

}

这不是给我想要的。对此,我们非常感谢任何解决方案

没有得到UIPickerView所需的定制。您能解释一下吗?如果您对代码不熟悉,请使用xib并将其加载到您不使用的委托中。@santak customization for selection indicator。例如,背景颜色、宽度使其成为圆角。我该如何实现这些目标?@SPUDERMAN您正在任何操作上显示UIPickerView,并在文本字段或标签中显示所选值。您是否需要如所附图片所示定制轮子或按钮?@santak好的,简单问题。如何使选择指示器的宽度最小化,如上图所示?它现在占据了整个屏幕的宽度。