设置导航条内容,一般设置三个地方:左边leftBarButtonItem 中间 titleView或者title 右边rightBarButtonItem
导航条上的内容往往用图片,默认只支持一种状态下的图片,如果需要多种状态下的图片,只能用UIButton来替代,以后不管是哪种项目,只要设置导航条,首先创建一个UIBarButtonItem+item的分类,创建一个类方法,因为每个控制器都可能会设置导航条
+ (UIBarButtonItem *)itemWithimage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:image forState:UIControlStateNormal];
[btn setImage:highImage forState:UIControlStateHighlighted];
[btn sizeToFit];
[btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
UIView *containView = [[UIView alloc] initWithFrame:btn.bounds];
[containView addSubview:btn];
return [[UIBarButtonItem alloc] initWithCustomView:containView];
}