我有一个UIBarButtonItem,“完成” - 在ViewController A的故事板IB中创建。
ViewController A是导航堆栈的根视图控制器。
如果我将视图控制器B推入导航堆栈然后再次弹出。完成按钮的字体粗细更改。
完成按钮的字体颜色应用于A.viewWillAppear(..),看起来非常像
doneButton.tintColor = [CMPThemes navigationBarItemColour]; // it's a blue
我从应用程序中剥离了所有外观代理代码(因为那里 是不止一种导航栏/按钮/标题样式出现 应用程序)所以我不是在寻找只能通过 外观代理...
我已在调试视图层次结构中检查了“完成”按钮 转换之前和之后的相同实例
我试图在pop
我不会在流程中的任何位置应用字体粗细
另外,在我看来,字体和字体大小似乎没有变化 过程。
在ViewController A中
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
...
self.navigationController?.pushViewController(vcB, animated: true)
...
在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
}
故事板看起来像:(我已将A和B添加到图像中以保持清晰度)。
如果有人意识到这个问题并且可以指出我正确的方向进行修复,那就太棒了!
答案 0 :(得分:1)
我发现了问题。应用的色调颜色不是问题。我认为,最初当它从故事板加载完成按钮时,doneButton样式等于 .done ,稍后当你弹出到ViewControllerA时,样式会以某种方式变为 .plan < / strong>,所以我认为在色调下面设置样式应该可以解决问题。
尝试使用以下代码更新ViewControllerA中的viewWillAppear方法:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
doneButton.tintColor = [CMPThemes navigationBarItemColour]; // it's a blue
doneButton.style = .done
}
希望它有所帮助!
答案 1 :(得分:0)