iOS 7 UINavigationBar背景图片隐藏标题视图
我制作了iOS应用程序,其中我希望我的应用程序与iOS 7兼容
我面对的问题是,当我在iOS 7上运行我的应用程序时,我的UINavigationBar
背景图像隐藏了我的titleview
和back button
:
-(void)viewDidLoad { [super viewDidLoad]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"top.png"] forBarMetrics:UIBarMetricsDefault]; self.title=@"Artist"; self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil]; }
另外,当我设置UINavigationBar
背景图像为零,它显示titleview
和back button
当我在iOS 7之前运行我的应用程序时,它正常工作。
请帮忙。 提前致谢。
tintColor
for bars的行为在iOS 7.0上已经改变,请检查下面的图片:
你可以看到
tintColor
:是导航栏中交互元素的颜色,包括button图像和标题。
barTintColor
是UINavigationBar
的背景颜色。
对于你的问题:你可以做到以下几点:
navigationBar.tintColor = [UIColor whiteColor]; navigationBar.barTintColor = [UIColor colorWithRed:6.0/255.0 green:12.0/255.0 blue:19.0/255.0 alpha:1.0];
默认的字体颜色是黑色的,所以你可能在黑色的背景上画一个黑色的字体。 尝试以下操作:
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], NSForegroundColorAttributeName,nil]];
检查视图的属性检查器上的属性扩展边缘,这会将导航栏底部的边缘延伸到屏幕顶部,以便您的背景图像位于正确的位置
检查ios7的转换指南,如果你想了解更多关于ios7的新东西的信息https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/TransitionGuide/index.html
以下代码为我工作
在viewDidLoad中
self.navigationController.navigationBar.tintColor=[UIColor whiteColor];