首先要隐藏系统自带UINavigationBar:
((UINavigationController *)([UIApplication sharedApplication].keyWindow.rootViewController )).navigationBarHidden = YES;
创建自定义的UINavigationBar:
UINavigationBar *bar= [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
bar.barStyle= UIBarStyleBlack;
添加到父视图:
[self.view addSubview:bar];
创建右按钮:
UINavigationItem *item = [[UINavigationItem alloc]initWithTitle:@"byMyself"];
UIBarButtonItem *btn = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addBtn:)];
item.rightBarButtonItem= btn;
[bar pushNavigationItem:item animated:YES];