Some summary of IOS Navigation use

Source: Internet
Author: User

1. First, add it.

AppDelegate.h

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Override point for customization after application launch. //Modify the navigation color[[Uinavigationbar appearance] Setbartintcolor:[uicolor colorwithred: -Green theBlue -Alpha1]]; Self.window=[[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds]; Viewcontroller*VC =[[Viewcontroller alloc] init]; Self.window.rootViewController=VC; Self.window.backgroundColor=[Uicolor Whitecolor];    [Self.window makekeyandvisible]; returnYES;}

2. Customizing the navigation bar

system self-bringing method // left button    Uibarbuttonitem *leftbutton = [[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemcamera Target:self Action: @selector (selectleftaction:)];     = LeftButton;         // Right button    Uibarbuttonitem *rightbutton = [[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem: Uibarbuttonsystemitemaction target:self Action: @selector (SelectRightAction2:)];     = Rightbutton;

Custom button pattern

Self.navigationItem.rightBarButtonItem = [[Uibarbuttonitem alloc] initwithimage:[self scaletosize:[uiimage Imagenamed:@"Myselect.png"] Size:cgsizemake ( -, -)] Style:uibarbuttonitemstyleplain target:self action: @selector (actionright:)];//Set Picture size-(UIImage *) Scaletosize: (UIImage *) img Size: (cgsize) size{//Create a bitmap context//and set it to the context that is currently being useduigraphicsbeginimagecontext (size); //draw a picture that changes size[img Drawinrect:cgrectmake (0,0, Size.width, Size.Height)]; //create a resized picture from the current contextuiimage* Scaledimage =Uigraphicsgetimagefromcurrentimagecontext (); //make the current context out of the stackUigraphicsendimagecontext (); //returns the new resized image    returnscaledimage;}

Set the style of the push return button

// push back button style    Uibarbuttonitem *item = [[Uibarbuttonitem alloc] Initwithtitle:@ ""  Style:uibarbuttonitemstyleplain Target:nil Action:nil];     = item;     // Self.navigationController.navigationBar.tintColor = [Uicolor graycolor];

Customize the style of the title and navigation bar

//Modify navigation bar title font size and color, background color[UIApplication Sharedapplication].statusbarstyle =uistatusbarstylelightcontent; [Self.navigationController.navigationBar setbartintcolor:[uicolor colorwithred:212/255.0GreenWuyi/255.0Blue $/255.0Alpha1]];                                                                      [Self.navigationController.navigationBar settitletextattributes:@{ Nsfontattributename:[uifont systemfontofsize: -], Nsforegroundcolorattributename:[uicolor Whitec                                                                                                                                            Olor] }];

This is changing the top battery icon, time and other colors

3. Some summary of the jump:

(1). Push jumps to the next page, takes its own navigation bar to jump off, the navigation bar is said to be his custom navigation bar properties

Nextviewcontroller *next =[[Nextviewcontroller alloc]init];    [Self.navigationcontroller Pushviewcontroller:next Animated:no];

(2). Push jumps to next page, next page hides navigation bar

// Hide Navigation bar -(void) viewwillappear: (BOOL) animated{    = YES;}

(3). Pop to any previous page

//return to view root controller[Self.navigationcontroller Poptorootviewcontrolleranimated:yes];//Pop to the specified page//For (Uiviewcontroller *controller in self.navigationController.viewControllers) {//if ([Controller Iskindofclass:[nextviewcontroller Class]]) {//Nextviewcontroller *a = (Nextviewcontroller *) controller;//[Self.navigationcontroller poptoviewcontroller:a animated:yes];//        }//    }//where the Nextviewcontroller is the view you want to jump to

(4). Present Jump without navigation bar

Homeviewcontroller *home = [[Homeviewcontroller alloc]init];        [Self presentviewcontroller:home animated:yes completion:^{                NSLog (@ "Login success! " );    }];

If it's a drag page,

Homeviewcontroller *home = [Self.storyboard instantiateviewcontrollerwithidentifier:@ "home" ];     = Self.sessionid;    [Self presentviewcontroller:home animated:yes completion:^{                NSLog (@ "Login success! " );    }];

Some summary of IOS Navigation use

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.