Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change text font in UIPickerView in iOS 7?

Tags:

ios

fonts

picker

I was able to change my font color but I also need to change font size, how can I accomplish that? Here's my code for chaning the color,

 - (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component {     NSString *title = _currencyName[row];     NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];      return attString;  } 

UPDATE: this didn't work:

 NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Light" size:40]}]; 
like image 608
user3121912 Avatar asked Dec 20 '13 07:12

user3121912


People also ask

How do I change my texting font on Iphone?

Go to Settings > Accessibility, then select Display & Text Size. Tap Larger Text for larger font options. Drag the slider to select the font size you want.

How do I change font size in Swift picker view?

Fill your Font name, Color, Size & Data Array with appropriate values. func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { var pickerLabel: UILabel? = (view as? UILabel) if pickerLabel == nil { pickerLabel = UILabel() pickerLabel?.


1 Answers

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {     UILabel* tView = (UILabel*)view;     if (!tView)     {        tView = [[UILabel alloc] init];        [tView setFont:[UIFont fontWithName:@"Helvetica" size:14]];        //[tView setTextAlignment:UITextAlignmentLeft];        tView.numberOfLines=3;     }     // Fill the label text here     tView.text=[wishvalues objectAtIndex:row];    return tView; } 
like image 126
mak Avatar answered Sep 23 '22 14:09

mak