Setting UILabel text to bold

bhzag picture bhzag · Jul 30, 2014 · Viewed 144.3k times · Source

How do you set the text for a UILabel to bold in Swift programmatically? My code so far:

    var label = UILabel(frame:theFrame)
    label.text = "Foo"

Answer

codester picture codester · Jul 30, 2014

Use font property of UILabel:

label.font = UIFont(name:"HelveticaNeue-Bold", size: 16.0)

or use default system font to bold text:

label.font = UIFont.boldSystemFont(ofSize: 16.0)