preferslargeTitles给出了约束错误,我之前已经完成了一个小应用程序,代码相同但没有错误,这里不仅是字体大小40上的错误,而且没有颜色红色,没有其他代码,然后将表固定起来查看。警告是
不能同时满足约束条件。可能下面列表中至少有一个约束是您不想要的。
代码
navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.topItem?.title = "LaViva Hotel"
//customization
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.hidesBarsOnSwipe = true
if let customFont = UIFont(name: "Rubik-Medium", size: 40.0) {
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor(red: 200/255, green: 70/255, blue: 70/255, alpha: 1), NSAttributedString.Key.font: customFont]
}发布于 2020-07-19 15:41:54
我已经运行了您的代码,但没有如您提到的那样发现任何错误,我还更改了一些代码行,它正在工作,现在您可以使用如下:-
self.navigationController?.navigationBar.topItem?.title = "LaViva Hotel"
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.hidesBarsOnSwipe = true
navigationController?.navigationBar.prefersLargeTitles = true
navigationController?.navigationBar.largeTitleTextAttributes =
[NSAttributedStringKey.foregroundColor: UIColor(red: 200/255, green: 70/255, blue: 70/255, alpha: 1),
NSAttributedStringKey.font: UIFont(name: "Rubik-Medium", size: 40) ??
UIFont.systemFont(ofSize: 40)]如果你想要更多的澄清,你应该提到你到底想要什么类型的输出,分享一些截图!
https://stackoverflow.com/questions/62980901
复制相似问题