0

当我尝试将其放入 Xcode 时,我在 Photoshop 中做了一个简单的设计,但 NavigationBar 出现了一些问题

我使用此代码更改 UINavigationBar 背景图像(PNG 透明图像):

UINavigationBar *navBar = [[self navigationController]navigationBar];
[navBar setBackgroundImage[UIImageimageNamed:@"navBar2.png"]forBarMetrics:UIBarMetricsDefault]

一切正常,但问题是图像出现在导航栏中没有透明度。

请有人帮我解决我到处搜索但没有任何满意答案的透明度问题
注意!我正在使用 IOS 5

4

4 回答 4

3

您可以尝试将导航栏设置为半透明。

[navBar setTranslucent: YES];
于 2012-07-31T18:58:30.417 回答
0

你的故事板中有它吗?尝试将导航栏的样式更改为黑色半透明。

于 2012-07-31T18:54:02.787 回答
0

您可以做的是将 navigationController 的视图的背景颜色设置为与主视图的背景颜色相同。

//Set your view's background color    
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"view_background"]]];

//Set your custom image for the navigationController
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed: @"navigation_bar_image"] forBarMetrics:UIBarMetricsDefault];

//And then set the background color of the navigationController the same as the one of the view
[self.navigationController.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"view_background"]]];
于 2013-02-22T13:41:48.627 回答
0
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationBar setShadowImage:[UIImage new]];
[self.navigationBar setTranslucent:YES];

并确保将色调颜色设置为默认值。

于 2014-12-09T17:57:19.050 回答