首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >prefersLargeTitles给约束误差

prefersLargeTitles给约束误差
EN

Stack Overflow用户
提问于 2020-07-19 13:26:32
回答 1查看 34关注 0票数 0

preferslargeTitles给出了约束错误,我之前已经完成了一个小应用程序,代码相同但没有错误,这里不仅是字体大小40上的错误,而且没有颜色红色,没有其他代码,然后将表固定起来查看。警告是

不能同时满足约束条件。可能下面列表中至少有一个约束是您不想要的。

代码

代码语言:javascript
复制
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]
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-19 15:41:54

我已经运行了您的代码,但没有如您提到的那样发现任何错误,我还更改了一些代码行,它正在工作,现在您可以使用如下:-

代码语言:javascript
复制
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)]

如果你想要更多的澄清,你应该提到你到底想要什么类型的输出,分享一些截图!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62980901

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档