I'm trying to add a custom font to a swift project and have a question for Swift's struct. Since I'm gonna make custom fonts with different sizes and I need to use string ("My custom font") multiple times, I want to make a variable for the strings but get the error.
struct Fonts {
let myFont = "My custom font"
let myFontBold = "My custom font bold"
static let customFontNormal = UIFont(name: self.myFont, size: 16.0)
static let customFontBold = UIFont(name: self.myFontBold, size: 16.0)
}
and I get this error message
Cannot use instance member 'myFont' within property initializer; property initializers run before 'self' is available.
I want to call the font like Fonts.customFontNormal or something similar, but is there a way to make a string variable and enable to access the value from a variable in the same struct?
staticfor some of this, but not all? Unrelated, the type isenum Font, notstruct Fonts. But why bother making a type instead of just extendingUIFont?