简体   繁体   中英

UIFont size not changing in UIPicker

I'm attempting to change the font and size of the elements in my UIPicker with the following code:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{

    UILabel *pickerViewLabel = (id)view;

    if (!pickerViewLabel) {
        pickerViewLabel= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width - 10.0f, [pickerView rowSizeForComponent:component].height)];
    }

    pickerViewLabel.backgroundColor = [UIColor clearColor];
    pickerViewLabel.text = _startTimeArray[row];
    pickerViewLabel.font = [UIFont fontWithName:@"Helvetica Neue Regular" size:(22)];

    return pickerViewLabel;
}

I'm able to change the type of font, but the size stays constant no matter what values I put in. Does anyone know why the font size is not changing? Thank you!

You have used wrong font name. Try HelveticaNeue . You can find all available font names here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM