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

Source: Internet
Author: User

Set the font color and size of the navigation bar title in iOS, and the friends you need can refer to below.




In peacetime 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.

Method One: (The way to customize the view, the average person will also use this way)

is to add a titleview in the navigation, you can use a label, and then set the label's background color transparent, font what the setting is very simple.

Customizing the title View

UILabel *titlelabel = [[UILabel
Alloc] initwithframe:CGRectMake (0,
0, (+ )];

Titlelabel. backgroundcolor = [uicolor
Graycolor];

Titlelabel. font = [uifont
Boldsystemfontofsize £ º];

Titlelabel. TextColor = [uicolor
Greencolor];

Titlelabel. textalignment =
Nstextalignmentcenter;

Titlelabel. Text =
@ " news ";

Self. Navigationitem. Titleview = Titlelabel;



Method Two: (It is also possible to modify the file size and color directly in the title displayed by default)

[Self.navigationController.navigationBar settitletextattributes:

@{nsfontattributename:[uifont Systemfontofsize:19],

Nsforegroundcolorattributename:[uicolor Redcolor]}];

Mode two is simpler and more convenient than the way one

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

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.