Set the font color and size of navigation bar headings in iOS

Source: Internet
Author: User
<span id="Label3"></p><p><p>In peacetime <span id="3_nwp">development projects, inevitably encounter changes in the navigation bar font size and color requirements, The general use of Custom view methods, in fact, there is a method. </span></p></p><p><p><span style="font-size: 16px;"><strong>Method One: (the Way to customize the view, the average person will also use this Way)</strong></span></p></p><p><p>is to <span id="1_nwp">add a titleview in the navigation, you can use a <span id="2_nwp">label, and then set the Label's background color transparent, font What the setting is very simple. </span></span></p></p><p class="p1"><p class="p1"><span class="s1">Customizing the title View</span></p></p><p class="p2"><p class="p2"><span class="s2">UILabel *titlelabel = [[<span class="s2">UILabel <span class="s3">alloc] <span class="s3">initwithframe:<span class="s3">cgrectmake (<span class="s4">0, <span class="s4">0, $ <span class="s4"> <span class="s4">44)];< /c14> </span></span></span></span></span></span></span></span></span></p></p><p class="p2"><p class="p2">Titlelabel. <span class="s2">backgroundcolor = [<span class="s2">uicolor <span class="s3">graycolor];</span> </span> </span></p></p><p class="p2"><p class="p2">Titlelabel. <span class="s2">font = [<span class="s2">uifont <span class="s3">boldsystemfontofsize:<span class="s4">];</span> </span> </span> </span></p></p><p class="p2"><p class="p2">Titlelabel. <span class="s2">TextColor = [<span class="s2">uicolor <span class="s3">greencolor];</span> </span> </span></p></p><p class="p3"><p class="p3"><span class="s5">Titlelabel. <span class="s2">textalignment<span class="s5"> = Nstextalignmentcenter<span class="s5">;</span> </span> </span></span></p></p><p class="p2"><p class="p2">Titlelabel. <span class="s2">text = <span class="s6">@ " <span class="s7">news <span class="s6">";</span> </span> </span> </span></p></p><p class="p5"><p class="p5"><span class="s5"><span class="s8">Self<span class="s5">. Navigationitem<span class="s5">. Titleview<span class="s5"> = titlelabel;</span> </span> </span></span></span></p></p><p class="p5"><p class="p5"><span class="s5"></span></p></p><p class="p5"><p class="p5"><strong><span class="s5" style="font-size: 16px;">Method Two: (it is also possible to modify the file size and color directly in the title displayed by Default)</span></strong></p></p><p class="p1"><p class="p1">[self.navigationController.navigationBar settitletextattributes:</p></p><p class="p1"><p class="p1">@{nsfontattributename:[uifont systemfontofsize:19],</p></p><p class="p1"><p class="p1">Nsforegroundcolorattributename:[uicolor <span id="0_nwp">redcolor]}];</span></p></p><p class="p1"><p class="p1"></p></p><p class="p1"><p class="p1">Mode two is simpler and more convenient than the way one</p></p><p><p>Set the font color and size of navigation bar headings in iOS</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.