是的,它可以实现在视图中使用它会出现
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBar.png"] forBarMetrics:UIBarMetricsDefault];
// 用于自定义后退按钮
UIButton* btnBack= [Utils createButtonWithTarget:self selector:@selector(btnBackClicked) frame:CGRectMake(0,5, 100, 40) bgimageName:@"tab_back.png" tag:0];//My method use yours
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:btnBack];
//use btnBack ref to change font title title color etc
我的 Utils 类代码来创建按钮
+ (UIButton *)createButtonWithTarget:(id)target
selector:(SEL)selector
frame:(CGRect)frame
bgimageName:(NSString *)imageName
tag:(NSInteger)aTag{
UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
button.frame = frame;
[button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
[button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
// in case the parent view draws with a custom color or gradient, use a transparent color
button.backgroundColor = [UIColor clearColor];
button.showsTouchWhenHighlighted = YES;
button.tag = aTag;
return [button autorelease];
}