【发布时间】:2009-09-04 19:33:26
【问题描述】:
我已将以下代码应用于我的应用程序以更改导航栏图像。
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
[self setNavigationBarTitle];
}
-(void)setNavigationBarTitle {
UIView *aViewForTitle=[[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)] autorelease];
UIImageView *aImg=[[UIImageView alloc] initWithFrame:CGRectMake(-8, 0, 320, 45)];
aImg.image=[UIImage imageNamed:@"MyTabBG.png"];
[aViewForTitle addSubview:aImg]; [aImg release];
UILabel *lbl=[[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 305, 45)] autorelease];
lbl.backgroundColor=[UIColor clearColor]; lbl.font=[UIFont fontWithName:@"Trebuchet MS" size:22];
lbl.shadowColor=[UIColor blackColor]; [lbl setShadowOffset:CGSizeMake(1,1)];
lbl.textAlignment=UITextAlignmentCenter; lbl.textColor=[UIColor whiteColor]; lbl.text=@"Mobile Tennis Coach Overview";
[aViewForTitle addSubview:lbl];
[self.navigationItem.titleView addSubview:aViewForTitle];
}
请看以下图片。你可以看到我面临的问题。
我的应用程序的每个视图控制器都有上述方法来设置导航栏背景。
然而,当我将一个新的视图控制器推送到我的应用程序时。将出现返回按钮。
我需要后退按钮才能出现。但是图片应该在后退按钮后面。
现在我有点困惑了。
你能帮我解决这个问题吗?
提前感谢您与我分享您的知识。
非常感谢。
【问题讨论】:
-
嗨 Sagar,普通按钮(即不是后退按钮)如何呈现?它工作正常还是有同样的问题?
-
在我以前的导航控制器中-视图将消失方法-我已将标题设置为后退-self.navigationItem.title=@"back"。
标签: iphone xcode uinavigationbar uinavigationitem