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]}];
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.
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?.
- (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; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With