2013-12-12 52 views
1

我有AppDelegate中的UINavigationBar樣式集,但它似乎沒有對我的應用程序生效。我正在使用XCode 5和我的代碼如下:UINavigationBar需要透明

- (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的

enter image description here

回答

0

[self.navigationController.navigationBar了setBackgroundImage:menuBackground forBarMetrics: UIBarMetricsDefault];

+0

我在哪裏添加該代碼? – Omar

+0

bettat方法是在創建UINavigationController的地方添加此方法,或者將其添加到 - (BOOL)應用程序下的AppDelegate.m文件中:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法。 –

+0

你也可以參考這個鏈接:[使UINavigationBar透明](http://stackoverflow.com/questions/2315862/make-uinavigationbar-transparent) –

相關問題