How to use SF Rounded font in SwiftUI?
I know the question is about SwiftUI, but I thought it could be helpful to also include an UIKit answer.
let fontSize: CGFloat = 24
// Here we get San Francisco with the desired weight
let systemFont = UIFont.systemFont(ofSize: fontSize, weight: .regular)
// Will be SF Compact or standard SF in case of failure.
let font: UIFont
if let descriptor = systemFont.fontDescriptor.withDesign(.rounded) {
font = UIFont(descriptor: descriptor, size: fontSize)
} else {
font = systemFont
}
Text("Your Text").font(.system(.body, design: .rounded))