- AppDelegate.m
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *root = [[RootViewController alloc] init];
//标题(中间位置)
root.title = @"首页";
//创建导航栏控制器
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点击事件
//修改字体啥的
self.navigationItem.title = @"返回";
[self.navigationController pushViewController:add animated:YES];
导航栏button样式
- AddViewController.m
self.view.backgroundColor = [UIColor greenColor];
self.title = @"第二页";
首页
点击右上角的加号,会进入第二页。
第二页
点击返回,到第一页。
self.navigationItem.prompt = @"欢迎访问www.baidu.com"; //文本显示在导航栏按钮(在最上方)
显示网址的样子
动画效果