【问题标题】:No tint color for a navigationBar in SwiftSwift 中的导航栏没有色调颜色
【发布时间】:2016-09-23 15:27:19
【问题描述】:

我在UINavigationController 上有一个扩展,它设置navigationBar.tintColor 并使其透明:

self.navigationBar.tintColor = UIColor.whiteColor()
self.navigationBar.shadowImage = UIImage()
self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)

但我想要的是有一个透明的导航栏,其中的可见项目根本没有色调。我添加了一个具有彩色背景图像的右侧导航栏项:

let rightButton = UIBarButtonItem(image: UIImage(named: "avatar")!,
                                  style: UIBarButtonItemStyle.Plain, 
                                  target: self,     
                                  action: #selector(self.rightNavBarItemAction))

navigationItem.rightBarButtonItem = rightButton

我没有将图像作为按钮的背景,而是使用白色占位符。使用UIColor.clearColor() 使按钮透明。

【问题讨论】:

标签: ios swift uinavigationcontroller uibarbuttonitem


【解决方案1】:

你可以试试这个:

self.navigationController?.navigationBar.barTintColor = UIColor.green

希望它对你有用。谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-21
    • 2021-01-01
    • 2014-09-01
    • 2015-11-03
    • 2016-05-04
    相关资源
    最近更新 更多