gpt4 book ai didi

ios - iOS 11 导航栏中大标题的多行

转载 作者:技术小花猫 更新时间:2023-10-29 10:17:36 24 4
gpt4 key购买 nike

是否可以让 iOS 11 中导航栏的新大标题显示多行? App Store 应用程序执行此操作,但我在当前文档中找不到任何内容来执行此操作。如果太长,标准行为只显示一行带省略号。

enter image description here

最佳答案

将以下代码添加到 viewWillAppear 中:

    navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationItem.largeTitleDisplayMode = .automatic

self.title = "Hello big text, For navigation large style bar"
navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black, NSAttributedStringKey.font : UIFont.preferredFont(forTextStyle: .largeTitle)]

var count = 0
for item in(self.navigationController?.navigationBar.subviews)! {
for sub in item.subviews{
if sub is UILabel{
if count == 1 {
break;
}
let titleLab :UILabel = sub as! UILabel
titleLab.numberOfLines = 0
titleLab.text = self.title
titleLab.lineBreakMode = .byWordWrapping
count = count + 1
}
}

}
self.navigationController?.navigationBar.layoutSubviews()
self.navigationController?.navigationBar.layoutIfNeeded()

后退按钮面临的问题将很快更新..

关于ios - iOS 11 导航栏中大标题的多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46578612/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com