【问题标题】:Translucent UINavigationBar半透明 UINavigationBar
【发布时间】:2014-11-05 09:52:07
【问题描述】:

我无法让我的 UINavigationBar 完全透明,只显示白色文本和按钮,因此我用于 ViewController 背景的 ImageView 在顶部完全可见。

我已经尝试过以下代码:

    // Set the BarTintColor to translucent and text colors to white
self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

但是this是结果,一个黑色的UINavigationBar,我该如何解决这个问题?

应用程序从这个ViewController 推送到这个ViewController,其中 UINavigationBar 逐渐变为红色。还有其他几个 ViewController 在做同样的淡入淡出动画,所以 UINavigationBar 是必需的

第一个 ViewController 中带有“Ny”按钮的部分将得到改进;)——我正在努力使用像 Photoshop 这样的工具

谢谢! 埃里克

【问题讨论】:

    标签: ios objective-c uiviewcontroller uinavigationbar uicolor


    【解决方案1】:

    添加这个

    self. navigationController.navigationBar.translucent = YES;
    

    【讨论】:

    • 得到相同的黑色 UINavigationBar :/ @ShahabQureshi
    【解决方案2】:

    这是我用来使导航栏透明的:

    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.translucent = YES;
    

    【讨论】:

      【解决方案3】:

      我发现这个非常相似question。 还有一个例子Gist

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-06-18
        • 1970-01-01
        • 1970-01-01
        • 2014-09-19
        • 1970-01-01
        • 1970-01-01
        • 2011-01-19
        • 1970-01-01
        相关资源
        最近更新 更多