iOS navigation controller common functions and Navigationbar Common Properties

Source: Internet
Author: User

The time of common function triggering of navigation controller

Triggered when view controller's views are going to appear

-(void) Viewwillappear: (BOOL) animated

Triggered when view controller's views already appear

-(void) Viewdidappear: (BOOL) animated

Triggered when view controller's views are going to disappear

-(void) Viewwilldisappear: (BOOL) animated

Triggered when view controller's views have disappeared

-(void) Viewdiddisappear: (BOOL) animated

When the next interface is push by the previous interface, such as a push B, four method execution order a (viewwilldisappear) >b (viewwillappear) >a (viewdiddisappear) >b ( Viewdidappear)

When a previous interface pops up by the latter interface, such as B pop A, four methods of execution order B (viewwilldisappear) >a (viewwillappear) >b (viewdiddisappear) >a ( Viewdidappear)

Navigationbar Common Properties

I. Direct configuration of the Navigationbar, so this action will have an effect on the content displayed on each interface Navigationbar (the effect is the same

)

1. Modify the Navigationbar color

Self.navigationController.navigationBar.barTintColor = [Uicolor redcolor];

2. Turn off the navigationbar effect of the wool glass

Self.navigationController.navigationBar.translucent = NO;

3. Hide the Navigationbar

Self.navigationController.navigationBarHidden = yes;4. Set a picture for Navigationbar

Different sizes of picture effects are different

:

1.320 * 44, will only give Navigationbar

Attached sheet

2. Height less than 44, and greater than 44 and less than 64: tile Navigationbar and display on status bar

3. Height equals 64: Entire picture in Navigationbar

and display on the status bar

[Self.navigationController.navigationBar setbackgroundimage:[uiimage imagenamed:@ "32050"] forbarmetrics: Uibarmetricsdefault];

Two. Individually customize the content displayed on Navigationbar of each interface (different display content for each interface), modify The Navigationitem of the view controller

1. Set the interface's

Title

Self.navigationItem.title = @ "Far East development

”;

2. Modify Titleview (middle display view

)

Uisegmentedcontrol*segment = [[uisegmentedcontrolalloc]initwithitems:@[@ ' group ', @ ' friends ']; self.navigationitem.titleview= segment;

3. Modifications

Navigationbar color Self.navigationController.navigationBar.barTintColor = [Uicolor Whitecolor];

4. Modify the Navigationbar,

Show content on the right

Uibarbuttonitem *right = [[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self Action: @selector (add:)];

Self.navigationItem.rightBarButtonItem = right;

5.

Modify Navigationbar, show content on left

Uibarbuttonitem*left = [[Uibarbuttonitemalloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemaddtarget: Selfaction: @selector

(add:)];

Self.navigationItem.leftBarButtonItem

= left;

iOS navigation controller common functions and Navigationbar Common Properties

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.