- AppDelegate.m
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *root = [[RootViewController alloc] init];
//標(biāo)題(中間位置)
root.title = @"首頁";
//創(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];

導(dǎo)航欄button樣式
- AddViewController.m
self.view.backgroundColor = [UIColor greenColor];
self.title = @"第二頁";

首頁
點(diǎn)擊右上角的加號,會進(jìn)入第二頁。

第二頁
點(diǎn)擊返回,到第一頁。
self.navigationItem.prompt = @"歡迎訪問www.baidu.com"; //文本顯示在導(dǎo)航欄按鈕(在最上方)

顯示網(wǎng)址的樣子

動畫效果