【发布时间】: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() 使按钮透明。
【问题讨论】:
-
stackoverflow.com/questions/17041778/… 试试这个链接,默认背景色是白色。
-
@ManishSingh 默认为蓝色
-
尝试将 barTintColor 设置为 clearColor
标签: ios swift uinavigationcontroller uibarbuttonitem