Use custom TTF fonts on iOS

Source: Internet
Author: User


The project would like to use a third-party font, query the solution on the StackOverflow, also toss a while, add success, examples are as follows:


1. Add the Xx.ttf font library to the project

2. Add a new line Fonts provided by application in the project's Xx-info.plist file , plus the name of the font library




3. Reference the name of the font library and set the font: [uifontfontwithname:@ "FontName" size: - ];


    UILabel *label = [[UILabel alloc] Initwithframe:cgrectmake (ten, +, +)];    Label.text = @ "This is a test. 123456 ";    Uifont *font = [Uifont fontwithname:@ "Wen Ding cs Medium line" size:24];    Label.font = font;    [Self.view Addsubview:label];


If you do not know the font name, you can traverse the font to query:

  For (NSString *fontfamilyname in [Uifont familynames])    {        NSLog (@ "Family: '%@ '", fontfamilyname);        For (NSString *fontname in [Uifont Fontnamesforfamilyname:fontfamilyname])        {            NSLog (@ "\tfont: '%@ '", FontName) ;        }        NSLog (@ "-------------");    }




Example demo:http://download.csdn.net/detail/duxinfeng2010/7639683


Reference Http://stackoverflow.com/questions/15447558/can-not-include-ttf-font-into-project



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.