I need to set the alignment of the text in picker view but my solutions doesn\'t work. This is my code so far. I used array to store values on the picker view.
i done with this code for UIlabel text show in center of tableView like:-
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)];
if (component == 0) {
label.font=[UIFont boldSystemFontOfSize:22];
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.text = [NSString stringWithFormat:@"%@", [source objectAtIndex:row]];
label.font=[UIFont boldSystemFontOfSize:22];
}
[label autorelease];
return label;
}
Code output is