You can configure the UIFont
used by the UINavigationBar
appearance
to use caps.
extension UIFont {
func getAllCapsFont(with size: CGFloat, andWeight weight: Weight) -> UIFont {
let fontDescriptor = UIFont.systemFont(ofSize: size, weight: weight).fontDescriptor
let upperCaseFeature: [UIFontDescriptor.FeatureKey: Int] = [
.featureIdentifier: kUpperCaseType,
.typeIdentifier: kUpperCaseSmallCapsSelector
]
let lowerCaseFeature: [UIFontDescriptor.FeatureKey: Int] = [
.featureIdentifier: kLowerCaseType,
.typeIdentifier: kLowerCaseSmallCapsSelector
]
let features = [upperCaseFeature, lowerCaseFeature]
let additions = fontDescriptor.addingAttributes([.featureSettings: features])
return UIFont(descriptor: additions, size: size)
}
}