当我添加背景图片时,uinavigationbar
它会隐藏我的标题uinavigationbar
,
这是我的代码,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
...
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed: @"BarBg.png"] forBarMetrics:UIBarMetricsDefault];
}
类中的代码:
int height = self.navigationController.navigationBar.frame.size.height;
int width = self.navigationController.navigationBar.frame.size.width;
UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, height)];
navLabel.text=@"Categories";
navLabel.backgroundColor = [UIColor clearColor];
navLabel.textColor = [UIColor whiteColor];
navLabel.font = [UIFont boldSystemFontOfSize:17];
navLabel.textAlignment = NSTextAlignmentCenter;
self.navigationItem.titleView = navLabel;
编写此代码后,我无法在导航栏上看到标题,标题位于导航栏图像后面。
请帮忙,提前谢谢..