UIPickerView 隐藏黑线或者修改黑线的颜色

// 每行显示什么内容
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    
    // 返回每一列的每一行展示的数据
    return self.mYuList[row];
}

// 每行显示什么内容
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    // UIPickerView隐藏黑线
//    [[pickerView.subviews objectAtIndex:1] setHidden:TRUE];
//    [[pickerView.subviews objectAtIndex:2] setHidden:TRUE];
    
    ((UIView *)[pickerView.subviews objectAtIndex:1]).backgroundColor = HexColor(0x80593E);
    
    ((UIView *)[pickerView.subviews objectAtIndex:2]).backgroundColor = HexColor(0x80593E);

    
    UILabel *myView = nil;
    
    myView = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 100, 40)];
    
    myView.textAlignment = NSTextAlignmentCenter;
    
    myView.text = self.mYuList[row];
    
    myView.textColor = HexColor(0x80593E);
    
    myView.font = [UIFont systemFontOfSize:24]; // 用label来设置字体大小
    
    myView.backgroundColor = [UIColor clearColor];
    
    return myView;
    
}
  • 效果图:
UIPickerView 隐藏黑线或者修改黑线的颜色_第1张图片

你可能感兴趣的:(UIPickerView 隐藏黑线或者修改黑线的颜色)