Hi,
In SwiftUI, I'm trying to show Text of Font.Weight value.
How to convert from Font.Weight type to String?
Thanks in advance.
In SwiftUI, I'm trying to show Text of Font.Weight value.
How to convert from Font.Weight type to String?
Thanks in advance.
Font.Weight doesn’t have the rawValue property so you can’t access it like this:
You could create your own enum that does have this feature:
Beware though that Apple could add or remove cases from Font.Weight.
Code Block Swift Font.Weight.bold.rawValue // bold
You could create your own enum that does have this feature:
Code Block Swift extension Font { enum <#Weight#>: String, CaseIterable, Equatable, Hashable { // add all cases from Font.Weight } }
Beware though that Apple could add or remove cases from Font.Weight.