Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

navigationTitle too long in swiftui

Is there any way to make the navigationTitle at the top to be a multiline one, or shrink when that is too long? Now, in my case, it shows "..." at the end because of not enough spaces to display. i have checked all other posts and none of the results are related to swiftui solution.

like image 298
user6539552 Avatar asked Sep 06 '25 03:09

user6539552


1 Answers

init() {
    UILabel.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).adjustsFontSizeToFitWidth = true
}

you can add this into your view struct

Reference to this SwiftUI Size to fit or word-wrap navigation title

like image 142
Kevin Angga Wijaya Avatar answered Sep 07 '25 17:09

Kevin Angga Wijaya