IOS Settings Navigation Bar II (set the navigation bar color, text color, the left button text and color)

Source: Internet
Author: User
Tags uikit

#import <UIKit/UIKit.h>@interface appdelegate:uiresponder <UIApplicationDelegate>  *window; @end
#import "AppDelegate.h"#import "KeyViewController.h"@interfaceappdelegate ()@end@implementationappdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {Self.window=[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]; //Override point for customization after application launch.Self.window.backgroundColor =[Uicolor Whitecolor]; //Initializing navigationUinavigationcontroller *navi =[[Uinavigationcontroller alloc] Initwithrootviewcontroller:[[keyviewcontroller alloc] init]; //set the background color of the navigation bar (after iOS7)[[Uinavigationbar appearance] Setbartintcolor:[[uicolor alloc] initwithred:133/255.0Green0Blue -/255.0Alpha1]]; //use a background image to set the color of the navigation bar (after iOS7)//[[Uinavigationbar appearance] setbackgroundimage:[uiimage imagenamed:@ "top bar Background"] Forbarmetrics:        Uibarmetricsdefault]; //set the color of text on the navigation bar (after iOS7)[[Uinavigationbar appearance] Settitletextattributes:@{nsforegroundcolorattributename:[uicolor OrangeColor]}]    ; Self.window.rootViewController=Navi;    [Self.window makekeyandvisible]; returnYES;}@end
#import <UIKit/UIKit.h>@interface  keyviewcontroller:uiviewcontroller@end 
#import "KeyViewController.h"#import "CashViewController.h"@interfaceKeyviewcontroller ()@end@implementationKeyviewcontroller- (void) viewdidload {[Super viewdidload]; Self.title=@"Cash Withdrawal"; UIButton*GETCASHBTN =[UIButton Buttonwithtype:uibuttontypecustom]; Getcashbtn.frame= CGRectMake ( -, -, -, $); [Getcashbtn settitle:@"Next Page"Forstate:0]; Getcashbtn.backgroundcolor=[Uicolor Orangecolor];    [Getcashbtn addtarget:self Action: @selector (getcashaction:) forcontrolevents:uicontroleventtouchupinside]; [Self.view addsubview:getcashbtn];}- (void) Getcashaction: (UIButton *) sender{Cashviewcontroller*CASHVC =[[Cashviewcontroller alloc] init]; [Self.navigationcontroller PUSHVIEWCONTROLLER:CASHVC animated:yes];}- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}@end
#import <UIKit/UIKit.h>@interface  cashviewcontroller:uiviewcontroller@end 
#import "CashViewController.h"@interfaceCashviewcontroller ()@end@implementationCashviewcontroller- (void) viewdidload {[Super viewdidload]; Self.title=@"Bank card Bindings"; Self.view.backgroundColor=[Uicolor Whitecolor]; //use the picture to set the button to the left of the navigation bar//Uibarbuttonitem *leftitem = [[Uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@ "Back button"] Style:uibarbutton        Itemstyleplain target:self Action: @selector (gobackaction:)]; //set the text of the left button on the navigation barUibarbuttonitem *leftitem = [[Uibarbuttonitem alloc] Initwithtitle:@"< back"Style:uibarbuttonitemstyleplain target:self Action: @selector (gobackaction:)]; //sets the color of the left button text in the navigation bar (and the color of the background image)Leftitem.tintcolor =[Uicolor Whitecolor]; Self.navigationItem.leftBarButtonItem=Leftitem;}/** * Click the event triggered by the left button on the navigation bar*/- (void) Gobackaction: (uibutton*) sender{[Self.navigationcontroller popviewcontrolleranimated:yes];}- (void) didreceivememorywarning {[Super didreceivememorywarning]; }@end

IOS Settings Navigation Bar II (set the navigation bar color, text color, the left button text and color)

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.