【问题标题】:How to make navigation bar background color to clearColor?如何使导航栏背景颜色为clearColor?
【发布时间】:2015-05-11 03:17:03
【问题描述】:

我的个人资料视图控制器嵌入在导航控制器中,并以彩色导航栏显示。但我想避免这种情况或如何使导航栏背景颜色为 clearColor。这样它就可以显示它下面的图像,例如。推特应用

【问题讨论】:

    标签: ios objective-c uinavigationcontroller uinavigationbar uinavigationitem


    【解决方案1】:

    试试这个代码:

    [self.navigationBar setBackgroundImage:[UIImage new]
                             forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.shadowImage = [UIImage new];
    self.navigationBar.translucent = YES;
    self.navigationController.navigationBar.tintColor = [UIColor clearColor];
    self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
    

    【讨论】:

      【解决方案2】:

      试试这个

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

      迅速

         self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
         self.navigationBar.shadowImage = UIImage()
         self.navigationBar.translucent = true
      

      【讨论】:

        【解决方案3】:

        非常有范儿, 你可以试试:

        YourNavigation.navigationBar.barTintColor = [UIColor clearColor];
        

        YourNavigation:输入您的 NavigationController。

        如果这有帮助,你可以帮我标记一下!

        谢谢

        【讨论】:

          【解决方案4】:

          将此行放入AppDelegate的didFinsihLaunchingWithOptions:

              [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; // This is for clear navigation bar 
              [[UINavigationBar appearance] setShadowImage:[UIImage new]]; // this for remvove line under the navigationbar
          

          【讨论】:

            【解决方案5】:
            [self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                                                          forBarMetrics:UIBarMetricsDefault];
            self.navigationController.navigationBar.shadowImage = [UIImage new];
            self.navigationController.navigationBar.translucent = YES;
            self.navigationController.view.backgroundColor = [UIColor clearColor];
            self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
            

            【讨论】:

              【解决方案6】:

              你不能让导航栏清晰。只需添加您的自定义视图,然后使其清晰。

              【讨论】:

                猜你喜欢
                • 2020-08-12
                • 2015-05-14
                • 1970-01-01
                • 2016-11-25
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2011-12-05
                相关资源
                最近更新 更多