Default Font for UINavigationBar Large Title in iOS 11?
On iOS 13 this is the exact font that is used for large titles in navigation bars. I compared screenshots pixel by pixel and it matches exactly!
UIFont.systemFont(ofSize: 34, weight: .bold)
The proper solution for getting the large title font is the following:
Objective-C:
UIFont *font = [UIFont preferredFontForTextStyle: UIFontTextStyleLargeTitle];
NSLog("%@", font);
Swift:
let font = UIFont.preferredFont(forTextStyle: .largeTitle)
print(font)
This will give the correct value even if the user has applied various accessibility and font size changes in the Settings app.
The above will print out the following by default (in a playground):
<UICTFont: 0x7fa865c05390> font-family: ".SFUIDisplay"; font-weight: normal; font-style: normal; font-size: 34.00pt
Note that the use of .largeTitle
in the code above must be called only with iOS 11. If your app supports iOS 10 or earlier, you must wrap that code in a proper use of @available
.
Edit: I opened the User Interface inspector and it says:
No need to code here :)