1

I changed my navigation bar title to the Apple's New York serif typeface using this code (based on this answer).

init() {
        // if NavigationBarTitle is with Large Font
        if let newYorkDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .largeTitle).withDesign(.serif) {
            UINavigationBar.appearance().largeTitleTextAttributes = [.font : UIFont(descriptor: newYorkDescriptor, size: 0)]
        }
    }

The navigation bar title shows up with the right font and font size, but it loses the bolded look that the normal navigation bar title has. How can I regain that? Is there a bold or font weight parameter I'm missing?

r829
  • 161
  • 1
  • 10

1 Answers1

1

The bold is part of font descriptor and you have to add it explicitly, like

UIFontDescriptor.preferredFontDescriptor(withTextStyle: .largeTitle)
     .withDesign(.serif)?.withSymbolicTraits(.traitBold)
Asperi
  • 228,894
  • 20
  • 464
  • 690