9
iOS 11中導航欄的新大標題顯示多行是否可能? App Store應用程序執行此操作,但在當前文檔中找不到任何內容來執行此操作。如果標準行爲太長,則只顯示一行帶省略號的行。iOS 11導航欄中大標題的多行顯示11
iOS 11中導航欄的新大標題顯示多行是否可能? App Store應用程序執行此操作,但在當前文檔中找不到任何內容來執行此操作。如果標準行爲太長,則只顯示一行帶省略號的行。iOS 11導航欄中大標題的多行顯示11
添加以下代碼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()
面對與後退按鈕將很快更新問題..
你收到這方面的任何解決方案? –