UIPickerView Custom Font
- by Lee Armstrong
I have the following code that I have found and tried to implement. I want to set the UIPickerView to have labels that I can customize the text in... When loading this it is just blank at the moment!
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *pickerLabel = (UILabel *)view;
NSString *text = @"TTT";
// Reuse the label if possible, otherwise create and configure a new one
if ((pickerLabel == nil) || ([pickerLabel class] != [UILabel class])) { //newlabel
CGRect frame = CGRectMake(0.0, 0.0, 270, 32.0);
pickerLabel = [[[UILabel alloc] initWithFrame:frame] autorelease];
pickerLabel.textAlignment = UITextAlignmentLeft;
pickerLabel.backgroundColor = [UIColor clearColor];
pickerLabel.font = [UIFont fontWithName:@"AmericanTypewriter" size:28];
}
pickerLabel.textColor = [UIColor brownColor];
return pickerLabel;
}