Search code examples
iosuipickerviewuifont

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!


Solution

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