【发布时间】:2022-12-24 16:40:09
【问题描述】:
我正在尝试更改导航控制器中提示的颜色,使其对于 iOS16 为白色而不是黑色。
import UIKit
class ParentViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor.blue //UIColor.lincsNavBarBlueColor()
appearance.titleTextAttributes[NSAttributedString.Key.foregroundColor] = UIColor.white
navigationItem.standardAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
navigationItem.title = "Hello there"
navigationItem.prompt = "This is the prompt"
}
}
我需要添加什么来更改提示颜色?谢谢。
【问题讨论】:
-
这可能是不可能的。多年来,“提示”一直是一纸空文。您不能指望对古老的过时功能发出现代命令。
-
您可以尝试说
self.navigationController?.navigationBar.barStyle = .black,但我真的不希望它起作用。