The document says use it will return SF Pro for UIFontDescriptorSystemDesignDefault . But did not work for me. It always returned SFUI-Regular or SFUI-Light based on the weight.https://developer.apple.com/documentation/uikit/uifontdescriptorsystemdesign?language=objcSo have to download the fonts for SF Pro. and use the .otf files https://developer.apple.com/fonts/ func sfProFont(style: UIFont.TextStyle, weight: UIFont.Weight = .regular, design: UIFontDescriptor.SystemDesign = .default , size: CGFloat) -> UIFont? {
guard let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
.addingAttributes([UIFontDescriptor.AttributeName.traits: [UIFontDescriptor.TraitKey.weight: weight]])
.withDesign(design) else {
return nil
}
return UIFont(descriptor: descriptor, size: size