UIPickerView Custom Font
Posted
by Lee Armstrong
on Stack Overflow
See other posts from Stack Overflow
or by Lee Armstrong
Published on 2009-08-01T06:29:54Z
Indexed on
2010/05/27
19:11 UTC
Read the original article
Hit count: 425
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;
}
© Stack Overflow or respective owner