Ios UINavigationBar需要透明
我在AppDelegate中设置了UINavigationBar样式,但它似乎对我的应用程序无效。我使用的是XCode 5,代码如下:Ios UINavigationBar需要透明,ios,objective-c,uinavigationbar,Ios,Objective C,Uinavigationbar,我在AppDelegate中设置了UINavigationBar样式,但它似乎对我的应用程序无效。我使用的是XCode 5,代码如下: - (void) customizeApp { UIImage* menuBackground = [UIImage imageNamed:@"menu-bar.png"]; [[UINavigationBar appearance] setBackgroundImage:menuBackground forBarMetrics:UIBarM
- (void) customizeApp
{
UIImage* menuBackground = [UIImage imageNamed:@"menu-bar.png"];
[[UINavigationBar appearance] setBackgroundImage:menuBackground forBarMetrics:UIBarMetricsDefault];
// Customize the title text for *all* UINavigationBars
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"HelveticaNeue-Light" size:0.0],
UITextAttributeFont,
nil]];
}
我不知道我做错了什么,为什么它不起作用。这是在XCode 4/iOS6中工作的
[self.navigationController.navigationBar setBackgroundImage:menubackgroundforbarmetrics:
UIBarMetricsDefault] 更好的方法是在创建UINavigationController的位置添加此方法,或者将其添加到-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions方法下的AppDelegate.m文件中。您也可以参考以下链接: