iOS: How can i set a non system font family, style, size of UILabel?

前端 未结 2 994
生来不讨喜
生来不讨喜 2021-01-14 16:35

I am trying to use a font which is not a system font in the bottom way

[pickerLabelLeft setFont:[UIFont fontWithName:@\"DaxOT-Bold\" size:20]];
[pickerLabelL         


        
相关标签:
2条回答
  • 2021-01-14 16:59

    Check out this short tutorial on how to use custom fonts.

    It's important to understand that the file name of the font (e.g. DaxOTBold.ttf) and the actual name of the font are 2 different things. Most of the time they are the same but there are some fonts that have a name that is slightly different from the file name. For example "Arial Rounded Bold.ttf" has the actual name "Arial Rounded MT Bold". Make sure that you are using the correct name.

    In this example in the plist you would use "Arial Rounded Bold.ttf" and in your code you'd use [UIFont fontwithName:@"Arial Rounded MT Bold" size:20]

    0 讨论(0)
  • 2021-01-14 17:19
    1. Download the font.
    2. Drag and drop the different font family in your project.
    3. Add the font family in .plist file (Fonts provided by application).
    4. Check whether your font family is added in your "Build Phases" or not.
    5. Now select a "New file" in your project and add a ".h" file in the project.
    6. In the ".h" file enter "#define any_name@"font_name"
    7. Now define it in the label setFont......

    You're all done but remember don't add the ".ttf" with your "font_name".

    Thanks!

    0 讨论(0)
提交回复
热议问题