Return to Snippet

Revision: 49971
at August 3, 2011 16:59 by ghiboz


Updated Code
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
    UILabel* tView = (UILabel*)view;
    if (!tView){
        tView = [[UILabel alloc] init];
            // Setup label properties - frame, font, colors etc
            ...
            //adjustsFontSizeToFitWidth property to YES
            tView.minimumFontSize = 8.;
            tView.adjustsFontSizeToFitWidth = YES;
    }
    // Fill the label text here
    ...
    return tView;
}


// altro modo completo sembrerebbe...
- (UIView *)pickerView:(UIPickerView *)pickerView
	    viewForRow:(NSInteger)row
	  forComponent:(NSInteger)component
	   reusingView:(UIView *)view {

  UILabel *pickerLabel = (UILabel *)view;

  if (pickerLabel == nil) {
    CGRect frame = CGRectMake(0.0, 0.0, 80, 32);
    pickerLabel = [[[UILabel alloc] initWithFrame:frame] autorelease];
    [pickerLabel setTextAlignment:UITextAlignmentLeft];
    [pickerLabel setBackgroundColor:[UIColor clearColor]];
    [pickerLabel setFont:[UIFont boldSystemFontOfSize:15]];
  }

  [pickerLabel setText:[pickerDataArray objectAtIndex:row]];

  return pickerLabel;

}

Revision: 49970
at August 3, 2011 16:57 by ghiboz


Initial Code
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
    UILabel* tView = (UILabel*)view;
    if (!tView){
        tView = [[UILabel alloc] init];
            // Setup label properties - frame, font, colors etc
            ...
            //adjustsFontSizeToFitWidth property to YES
            tView.minimumFontSize = 8.;
            tView.adjustsFontSizeToFitWidth = YES;
    }
    // Fill the label text here
    ...
    return tView;
}

Initial URL

                                

Initial Description

                                

Initial Title
change font size uipicker

Initial Tags

                                

Initial Language
Objective C