在我的应用代表中,我指定了一个透明工具栏(如问题18969248的回答中所建议): -
代码是:
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
navigationBarAppearance.backgroundColor = [UIColor clearColor];
[navigationBarAppearance setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
navigationBarAppearance.shadowImage = [[UIImage alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
这适用于推送到导航控制器堆栈的所有视图控制器,但不适用于根视图控制器(从NIB加载)。 如何在根视图控制器的导航栏中获得透明度?
答案 0 :(得分:0)
如果您使用的是故事板,也许您应该以这种方式通过AppDelegate以编程方式加载RootViewController:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"yourStoryboard"
bundle: nil];
YourCustomRootViewController *customRootVC = (YourCustomRootViewController*) [mainStoryboard instantiateViewControllerWithIdentifier:@"firstAddProductViewController"];
// If you're not using storyboard, simply instantiate it this way
YourCustomRootViewController *customRootVC = [[YourCustomRootViewController alloc] initWithNibName:@"yourNib" bundle:nil];
/* In here, you want to add the code relative to the navigation bar of your rootVC */
[self.window setRootViewController:customRootVC];
}