change font size uipicker


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
  2. UILabel* tView = (UILabel*)view;
  3. if (!tView){
  4. tView = [[UILabel alloc] init];
  5. // Setup label properties - frame, font, colors etc
  6. ...
  7. //adjustsFontSizeToFitWidth property to YES
  8. tView.minimumFontSize = 8.;
  9. tView.adjustsFontSizeToFitWidth = YES;
  10. }
  11. // Fill the label text here
  12. ...
  13. return tView;
  14. }
  15.  
  16.  
  17. // altro modo completo sembrerebbe...
  18. - (UIView *)pickerView:(UIPickerView *)pickerView
  19. viewForRow:(NSInteger)row
  20. forComponent:(NSInteger)component
  21. reusingView:(UIView *)view {
  22.  
  23. UILabel *pickerLabel = (UILabel *)view;
  24.  
  25. if (pickerLabel == nil) {
  26. CGRect frame = CGRectMake(0.0, 0.0, 80, 32);
  27. pickerLabel = [[[UILabel alloc] initWithFrame:frame] autorelease];
  28. [pickerLabel setTextAlignment:UITextAlignmentLeft];
  29. [pickerLabel setBackgroundColor:[UIColor clearColor]];
  30. [pickerLabel setFont:[UIFont boldSystemFontOfSize:15]];
  31. }
  32.  
  33. [pickerLabel setText:[pickerDataArray objectAtIndex:row]];
  34.  
  35. return pickerLabel;
  36.  
  37. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.