The use of Navigationcontroller and finishing

Source: Internet
Author: User

1. Set the background color of the Navigationbar:

Self. Navigationcontroller. Navigationbar. Bartintcolor = [uicolor redcolor];

2. Set the title on the Navigationbar

Self. Navigationitem. Title = @ "Test";

< Span class= "S4" >3. Set the font size and color (using rich text) for headings on Navigationbar

Self. Navigationcontroller. Navigationbar. Titletextattributes = [nsdictionary Dictionarywithobjectsandkeys:[uicolor Yellowcolor],nsforegroundcolorattributename,[ uifont systemfontofsize:50 ],nsfontattributenamenil ];

< Span class= "S1" > < Span class= "S3" > 4. Setting Navigationbar background Image:

< Span class= "S3" > < Span class= "S1" > /span>  [self. Navigationcontroller. Navigationbar setbackgroundimage:[UIImage< Span class= "S1" > imagenamed:@ "1" forbarmetrics:uibarmetricsdefault];

< Span class= "S1" > < Span class= "S3" > 5. Hide/Show back key

< Span class= "S1" > < Span class= "S3" > in the interface setting where the return key needs to be hidden:

< Span class= "S1" > < Span class= "S3" > /span> self. Navigationitem. Hidesbackbutton = no

6. Keep The return arrow, remove the return title or change to another title

Set in the push-in top-level interface:

Uibarbuttonitem *backitem = [[uibarbuttonitem alloc] init];

Backitem. title = @ ""; (Don't set an empty string for the title, just write the string in the other header)

    Self. Navigationitem. Backbarbuttonitem = backitem;

7. Change the return key and title color

Self. Navigationcontroller. Navigationbar. Tintcolor = [uicolor whitecolor];

< Span class= "S3" >8. Custom Rightbutton

  Method one:          uibarbuttonitem *button= [[Uibarbuttonitem alloc] Initwithimage:nil style:u Ibarbuttonitemstyledone target:self Action: @selector (Action:)];           Self.navigation.rightBarButtonItem = button;  Method Two:          uibutton *button =[[Uibu Tton Alloc] Initwithframe:cgrectmake (0,0,30,30)];          [button setimage:[uiimage imagenamed:@ ""] forstate:uicontrolstatenormal];          [button addtarget:self action: @selector (action:) forcontrolevents:uicontroleventtouchupinside];           Uibarbuttonitem *rightitem = [[Uibarbuttonitem alloc] initwithcustomview:button];          self.navigationitem.rightbarbuttonitem = rightitem; 

  

The use of Navigationcontroller and finishing

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.