- AppDelegate.m
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *root = [[RootViewController alloc] init];
//標(biāo)題(中間位置)
root.title = @"首頁(yè)";
//創(chuàng)建導(dǎo)航欄控制器
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:root];
self.window.rootViewController = navController;
[_window makeKeyAndVisible];
leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(selectLeft:)];
self.navigationItem.leftBarButtonItem = leftButton; // 左邊的button
rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(selectRight:)];
self.navigationItem.rightBarButtonItem = rightButton; // 右邊的button
AddViewController *add = [[AddViewController alloc] init]; // 右button點(diǎn)擊事件
//修改字體啥的
self.navigationItem.title = @"返回";
[self.navigationController pushViewController:add animated:YES];
- AddViewController.m
self.view.backgroundColor = [UIColor greenColor];
self.title = @"第二頁(yè)";
點(diǎn)擊右上角的加號(hào)揭北,會(huì)進(jìn)入第二頁(yè)扳炬。
點(diǎn)擊返回,到第一頁(yè)罐呼。
self.navigationItem.prompt = @"歡迎訪問(wèn)www.baidu.com"; //文本顯示在導(dǎo)航欄按鈕(在最上方)