//添加标题
self.navigationItem.title = @"nav";
//添加图片
self.navigationItem.titleView =[UIButton buttonWithType:UIButtonTypeContactAdd];
//在iOS7以后
//默认会把导航条上的按钮渲染成蓝色
//style不管怎么设置都没有任何效果
//不管image是什么颜色,都会被渲染成蓝色
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"back" style:UIBarButtonItemStyleDone target:self action:@selector(back)];
//在iOS7以后避免图片被渲染为蓝色
UIImage *image = [UIImage imageNamed:@"menu"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:image style:UIBarButtonItemStyleDone target:self action:@selector(push)];
//如果要给navigationBar上按钮设置俩张图片,需要定义button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"cell_OK"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"cell_NO"] forState:UIControlStateHighlighted];
//控制的尺寸由图片决定,仅仅是设置尺寸,不能设置位置
[button sizeToFit];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];