I’m a beginner with swift and have reviewed this site to understand how importing custom fonts work. I’ve also reviewed this StackOverflow question which didn’t seem to solve my specific issue
Upon reviewing the site, I’ve added the .tts file Lovelo-Black to the project and plist.
private let loginButton: UIButton = {
let button = UIButton()
button.setTitle("log in", for: .normal)
button.layer.masksToBounds = true
button.layer.cornerRadius = Constants.cornerRadius
button.backgroundColor = UIColorFromHex(rgbValue: 0x00FF9C,alpha: 1)
button.setTitleColor(.black, for: .normal)
button.titleLabel?.font = UIFont(name: "Lovelo-Black") //issue here
return button
Is it possible to make the button use the Lovelo-Black font? Ideally, I would like it to look like this
If it is possible, what should I replace the 8th line with?
2
Answers
Make sure you add the fonts correctly to your project..
check this link
Use the correct font name
In swiftUI you can use custom function from Font to initialise and use any custom fonts. have a look at bellow example code.
Which generates bellow result