Dam*_*amo 6 uinavigationcontroller uibarbuttonitem ios
我有一个UIBarButtonItem,"完成" - 在ViewController A的故事板IB中创建.
ViewController A是导航堆栈的根视图控制器.
如果我将视图控制器B推入导航堆栈然后再次弹出.完成按钮的字体粗细更改.
完成按钮的字体颜色应用于A.viewWillAppear(..),看起来非常像
doneButton.tintColor = [CMPThemes navigationBarItemColour]; // it's a blue
Run Code Online (Sandbox Code Playgroud)
我从应用程序中删除了所有外观代理代码(因为应用程序中出现了多种导航栏/按钮/标题样式)所以我不是在寻找只能通过外观代理完成的修复程序. .
我已经在调试视图层次结构中检查了Done按钮在转换之前和之后是相同的实例
我试图在弹出后重新应用色调颜色
我不会在过程中的任何位置应用字体粗细
另外,在我看来,字体和字体大小在此过程中似乎没有变化.
在ViewController中
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
...
self.navigationController?.pushViewController(vcB, animated: true)
...
Run Code Online (Sandbox Code Playgroud)
在ViewController B中
viewDidLoad() {
...
let backButton = UIBarButtonItem(image: UIImage(named: "arrowLeft"), style: .plain, target: self, action: #selector(goBack))
backButton.tintColor = CMPThemes.popoverNavigationBarItemColour()
self.navigationItem.leftBarButtonItem = backButton
}
Run Code Online (Sandbox Code Playgroud)
故事板看起来像:(我已将A和B添加到图像中以保持清晰度).
如果有人认识到这个问题并且可以指出我正确的方向进行修复,这将是非常好的!
我发现了问题。应用的色调颜色不是问题。我认为,最初当它从情节提要加载完成按钮时,完成按钮样式等于.done,后来当您弹出到 ViewControllerA 时,样式以某种方式更改为.plan,所以我认为将样式设置为低于色调应该解决问题。
尝试使用以下代码更新 ViewControllerA 中的 viewWillAppear 方法:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
doneButton.tintColor = [CMPThemes navigationBarItemColour]; // it's a blue
doneButton.style = .done
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你!