Created
March 11, 2023 07:14
-
-
Save theevo/e1d7ef73a5fa48c4c66b5a0fc27bbc1a to your computer and use it in GitHub Desktop.
why does preferredFontDescriptor return an optional?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var countdownTimerLabel: UILabel = UILabel() | |
countdownTimerLabel.font = boldFont() ?? UIFont.systemFont(ofSize: 75, weight: .regular) | |
private func boldFont() -> UIFont? { | |
guard let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .largeTitle).withSymbolicTraits(.traitBold) else { return nil } | |
return UIFont(descriptor: descriptor, size: 75) | |
} | |
print("What font? \(countdownTimerLabel.font.fontName)") // .SFUI-Bold |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment