How to declare and initialize a variable type .headline?

How can I declare a variable to change the font?

The compiler indicates that it must be type CGFont.

so:

var typeFont: CGFont //but I don't know how to initialize

How is the correct way to give an initial value?

Thanks

Answered by Claude31 in 706544022

You can do this:

    var myFont = CGFont(UIFont(name: "Helvetica", size: 22.0)!.fontName as CFString)

See more details here: https://stackoverflow.com/questions/26035041/converting-uifont-to-cgfont-in-swift

Accepted Answer

You can do this:

    var myFont = CGFont(UIFont(name: "Helvetica", size: 22.0)!.fontName as CFString)

See more details here: https://stackoverflow.com/questions/26035041/converting-uifont-to-cgfont-in-swift

How to declare and initialize a variable type .headline?
 
 
Q