I am using navigation controller, and I've set to true its navigation bar's prefersLargeTitle
property. Everything works fine, but when the text of my title becomes too big, it doesn't fit in space. Here how it looks:
Is it possible to somehow make the title (while the navigation bar's prefersLargeTitle
property is set to true) dynamically adjust its font size, and if it is so, how to achieve that?
Use navigationBarTitle(_:) to set the title of the navigation bar. This modifier only takes effect when this view is inside of and visible within a NavigationView .
The appearance settings for the navigation bar when the edge of scrollable content aligns with the edge of the navigation bar. iOS 13.0+ iPadOS 13.0+ Mac Catalyst 13.1+ tvOS 13.0+
All you need is:
UILabel.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).adjustsFontSizeToFitWidth = true
Working also with SwiftUI on iOS 15.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With