Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift: Bolding UIButton


Is it possible to bold the font in a UIButton? With label, it's pretty simple such as:

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

But this doesn't work for buttons.

like image 433
Snorlax Avatar asked May 13 '16 17:05

Snorlax


2 Answers

For a UIButton I tried this and works:

Swift 2

testButton.titleLabel?.font = UIFont.boldSystemFontOfSize(18)

Swift 3 & 4

testButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)

(Thank's to ConfusionTowers)

like image 105
ciccioska Avatar answered Oct 12 '22 00:10

ciccioska


Swift 4+

button.titleLabel?.font = UIFont.systemFont(ofSize: 22.0, weight: .bold)
like image 37
dbrownjave Avatar answered Oct 12 '22 02:10

dbrownjave