Skip to content

Instantly share code, notes, and snippets.

@max-potapov
Created October 19, 2017 15:33
Show Gist options
  • Save max-potapov/c6a8cd1b85df89e65ec5f35dada56b01 to your computer and use it in GitHub Desktop.
Save max-potapov/c6a8cd1b85df89e65ec5f35dada56b01 to your computer and use it in GitHub Desktop.
Swift 4: UIFont small caps extension
extension UIFont {
func smallCapsFont() -> UIFont {
let attributes: [UIFontDescriptor.FeatureKey: Any] = [
.featureIdentifier: kLowerCaseType,
.typeIdentifier: kLowerCaseSmallCapsSelector
]
let descriptor = fontDescriptor.addingAttributes([
.featureSettings: [attributes],
.name: fontName
])
return UIFont(descriptor: descriptor, size: pointSize)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment