0

I have gone through this answer and others. I can't seem to center these columns.

enter image description here

This is my code:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
    NSLog(@"%s", __FUNCTION__);
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120.0, 44.01)];
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:18];
    label.text = [NSString stringWithFormat:@" %d", row+1];
    return label;    
}

Any ideas what I'm doing wrong?

Update with IB attributes inspector:

enter image description here

Community
  • 1
  • 1
ICL1901
  • 7,632
  • 14
  • 90
  • 138
  • 1
    When I drop this code into a fresh project, it centers perfectly. Are you doing something *else* with your UIPickerViews? How do you get the black box behind them? Did you just set the background color on the pickerview or did you embed the picker view in something else? – Michael Dautermann Nov 25 '13 at 01:26
  • Hi, thanks for trying this. I have the picker background set in IB. I updated my question with the attributes inspector settings. Basically, just centering. This VC is not embedded in another, just pushed. – ICL1901 Nov 25 '13 at 02:48
  • OK, I got it. I had a widthForComponent method, that I really didn't need. Thank you again for helping. – ICL1901 Nov 25 '13 at 03:03

0 Answers0