Issues with setting some different font for UILabel

后端 未结 3 1701
花落未央
花落未央 2021-01-31 12:19

I would like to set the font size and familyname to the titleLabel. //Helvetica Neue UltraLight

 [titleLabel setFont:[UIFont fontWithName:@\"Helvetica Neue Ultr         


        
3条回答
  •  日久生厌
    2021-01-31 12:34

    You use wrong font name, correct one will be:

    [titleLabel setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:25.0f]]; 
    

    You can see the list of all available font names for a given font family using +fontNamesForFamilyName: method in UIFont, e.g.:

    [UIFont fontNamesForFamilyName:@"Helvetica Neue"]
    

    Edit: Also mind that some fonts may not be present on all versions of iOS as Apple gradually adds (and sometimes probably removes) fonts from standard OS set.

    It appears that "HelveticaNeue-UltraLight" font present in OS starting 5.0 version. If you want to use it in older OS versions you'll need to embed it to you application - check for example this answer for details how to do that

提交回复
热议问题