【发布时间】:2013-12-20 13:22:18
【问题描述】:
我正在开发一个应用程序,并希望使导航栏透明。这是可能的还是导航栏是可见的还是完全隐藏的?在下图中,我希望 NavBar 清晰但后退箭头仍然可见。同样,我将如何更改后退按钮的文本。
谢谢!
【问题讨论】:
标签: ios ios7 uinavigationbar
我正在开发一个应用程序,并希望使导航栏透明。这是可能的还是导航栏是可见的还是完全隐藏的?在下图中,我希望 NavBar 清晰但后退箭头仍然可见。同样,我将如何更改后退按钮的文本。
谢谢!
【问题讨论】:
标签: ios ios7 uinavigationbar
以下是为您的应用设置可见导航的方法。这是完整的指南:http://www.appcoda.com/customize-navigation-status-bar-ios-7/
在您的 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法中添加以下代码
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
// iOS 7 Changes - Set the Font,Font Size and Navigation bar Background
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x0219FF)]; //324F85 color you want to set
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
shadow, NSShadowAttributeName,
[UIFont fontWithName:@"Helvetica Neue" size:21.0], NSFontAttributeName, nil]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
【讨论】:
[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.0]];
在您的视图控制器中添加以下代码以更改后退按钮的文本颜色。
[navController.navigationBar setTintColor:[UIColor colorWithRed:68.0/255.0 green:91.0/255.0 blue:120.0/255.0 alpha:1.0]];
或在您的应用委托中添加以下代码
[[UINavigationBar appearance] setTintColor:[UIColor yellowColor]];
【讨论】:
关于你的第二个答案,这有点奇怪,但后退按钮实际上也属于它支持的视图控制器。所以在那个视图控制器中,你应该把
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
更改为您选择的标题
【讨论】: