use*_*930 0 uinavigationcontroller uibarbuttonitem uibarbuttonitemstyle ios swift
我正在使用以下代码向我的导航控制器添加一个右栏按钮viewDidLoad
:
var b = UIBarButtonItem(
image: UIImage(named: "settings"),
style: .plain,
target: self,
action: #selector(sayHello(sender:))
)
self.navigationItem.rightBarButtonItem = b
Run Code Online (Sandbox Code Playgroud)
我的settings
png 文件是白色的,但是当我运行应用程序时,我看到的是默认blue
颜色。不管怎样,我想把它改成红色。我该怎么做?
我试过这个:
let navigationBarAppearnce = UINavigationBar.appearance()
navigationBarAppearnce.tintColor = UIColor.red
Run Code Online (Sandbox Code Playgroud)
但它没有用。这样做的正确方法是什么?
你有没有尝试过:
let navigationController = UINavigationController() //not how you should actually get it, but just for purpose of example
navigationController.navigationBar.tintColor = UIColor.red
Run Code Online (Sandbox Code Playgroud)
编辑:
我实际上使用以下内容:
navigationController.navigationBar.barTintColor = UIColor.red
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2825 次 |
最近记录: |