iOS Custom fonts and categories

Source: Internet
Author: User
<span id="Label3"></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span style="margin:0px; padding:0px">1: Get font file</span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">Download font files from various channels ttf, website or from other IPA to buckle Out. (take Fzltxh.ttf as an Example)</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span style="margin:0px; padding:0px">2: Copy the Fzltxh.ttf file to the project</span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span style="margin:0px; padding:0px">3: Add the item in Info.plist:</span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">Fonts provided by Application (uiappfonts) can add one or more item,</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">such as Item0--fzltxh.ttf</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span style="margin:0px; padding:0px">4: find out the real font name:</span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">Because when using fonts, to use the real name of the font, rather than the file name, you can use the following code to traverse the font names available for the current device.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">Then find the real name of the font you just Added.</p></p><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; border-color:rgb(221,221,221) rgb(221,221,221) rgb(221,221,221) rgb(108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:Consolas,‘Bitstream Vera Sans Mono‘,‘Courier New‘,Courier,monospace!important; color:black!important; background-color:rgb(225,255,252)"><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; Border-color:rgb (221,221,221) RGB (221,221,221) RGB (221,221,221) RGB (108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:consolas, ' bitstream Vera Sans Mono ', ' Courier New ', courier,monospace!important; color:black!important; Background-color:rgb (225,255,252) "> Nsarray *familynames = [uifont familynames]; For (nsstring *familyname in familynames) {printf ("Family:%s \ n", [familyname utf8string]); Nsarray *fontnames = [uifont fontnamesforfamilyname:familyname]; For (nsstring *fontname in fontnames) {printf ("\tfont:%s \ n", [fontname utf8string]); } }</pre></pre><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">  </p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span class="s1" style="margin:0px; padding:0px">Fzltxhk--gbk1-0 This is the real use name of this Font.</span></p></p><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span style="margin:0px; padding:0px">5: using Fonts</span></p></p><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; border-color:rgb(221,221,221) rgb(221,221,221) rgb(221,221,221) rgb(108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:Consolas,‘Bitstream Vera Sans Mono‘,‘Courier New‘,Courier,monospace!important; color:black!important; background-color:rgb(225,255,252)"><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; border-color:rgb(221,221,221) rgb(221,221,221) rgb(221,221,221) rgb(108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:Consolas,‘Bitstream Vera Sans Mono‘,‘Courier New‘,Courier,monospace!important; color:black!important; background-color:rgb(225,255,252)">[uifont fontwithname:@ "fzltxhk--gbk1-0" size:fontsize];</pre></pre><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">  </p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span style="margin:0px; padding:0px">6: Unified Replacement</span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">If you want to replace the old project font as a whole, and do not want to change the existing code, you can rewrite</p></p><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span class="s1" style="margin:0px; padding:0px">Systemfontofsize Method.</span></p></p><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; border-color:rgb(221,221,221) rgb(221,221,221) rgb(221,221,221) rgb(108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:Consolas,‘Bitstream Vera Sans Mono‘,‘Courier New‘,Courier,monospace!important; color:black!important; background-color:rgb(225,255,252)"><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; border-color:rgb(221,221,221) rgb(221,221,221) rgb(221,221,221) rgb(108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:Consolas,‘Bitstream Vera Sans Mono‘,‘Courier New‘,Courier,monospace!important; color:black!important; background-color:rgb(225,255,252)"> uifont+custom.h// tujing//// Created by Willbin on 15/1/13.// Copyright (c) 2015 willbin. All rights reserved.//#import <UIKit/UIKit.h> @interface uifont (tjcustom) + (uifont *) systemfontofsize: (cgfloat) fontSize; @end</pre></pre><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; border-color:rgb(221,221,221) rgb(221,221,221) rgb(221,221,221) rgb(108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:Consolas,‘Bitstream Vera Sans Mono‘,‘Courier New‘,Courier,monospace!important; color:black!important; background-color:rgb(225,255,252)"><pre class="brush:objc;gutter:true;" style="margin-top:10px; margin-bottom:10px; padding:5px; white-space:pre-wrap; border-width:1px 1px 1px 3px; border-style:solid; border-color:rgb(221,221,221) rgb(221,221,221) rgb(221,221,221) rgb(108,226,108); font-size:1em!important; line-height:1.1em!important; font-family:Consolas,‘Bitstream Vera Sans Mono‘,‘Courier New‘,Courier,monospace!important; color:black!important; background-color:rgb(225,255,252)"> uifont+custom.m// tujing//// Created by Willbin on 15/1/13.// Copyright (c) 2015 willbin. All rights reserved.//#import "uifont+custom.h" @implementation uifont (tjcustom) + (uifont *) systemfontofsize: (cgfloat ) fontsize{ return [uifont fontwithname:@ "fzltxhk--gbk1-0" size:fontsize];} @end</pre></pre><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">  </p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px">In that case, the original writing</p></p><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><p class="p1" style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; color:rgb(51,51,51); font-family:verdana,Arial,Helvetica,sans-serif; font-size:13.3333330154419px; line-height:24px"><span class="s1" style="margin:0px; padding:0px">The Systemfontofsize method is replaced by a new method, which results in an overall substitution.</span></p></p><p><p> iOS custom fonts and categories </p> </p></span>

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.