ios - 无法为 UIBarButtonItem 设置背景 = UIColor.clearColor()

标签 ios swift

我可以为 UIButton 设置 clearColor

var btn = UIButton()
btn.backgroundColor = UIColor.clearColor() 

但是我不能为 UIBarButtonItem 设置这个。

最佳答案

您可以创建一个按钮,然后使用 UIBarButtonItem(customView: yourButton) 初始化,或者您可以全局设置条形按钮项目 tintColor:

UIBarButtonItem.appearance().tintColor = UIColor.clearColor()

我假设您不希望所有的条形按钮项目都使用清晰的颜色,因此第一个解决方案可能就是这里的方法。

关于ios - 无法为 UIBarButtonItem 设置背景 = UIColor.clearColor(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38656909/

相关文章:

ios - 当包含在 UITableViewCell 中时将 hidden 设置为 false 后,Accessibility Inspector 看不到 UIImageView

ios - 为什么@nonescaping 闭包不需要 [weak self]?

swift - UISlider 如何在 self 可用之前调用 setValue() 方法?

ios - 如何在WKWebview上添加UIButton?

ios - 10.6 应用被拒绝 - 专家可以帮助我了解要更改的内容吗?

ios - 如何在 iOS 中使 UIAlertView 变大?

ios - 根据屏幕尺寸,两个 UIButton 之间的距离?

swift - 子对象可以在父对象的 deinit 期间引用其父对象吗?

ios - 如何使 UIAlertController 消息可选择

ios - 在框架和使用框架的应用程序之间使用 Google maps sdk