Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom font title for UIButton

Is there a way to have custom fonts to the title of a button.

like image 898
xydev Avatar asked Nov 22 '10 04:11

xydev


People also ask

How to set font for UIButton?

To set a different font on UIButton programmatically you will need to create a new instance of UIFont object. The initializer of UIFont accepts two arguments: name and size. where the “GillSans-Italic” is a font name you want to set.

How do I change the button title color in Swift?

Is-it possible to change the color of the Title for the button ? Usually, use setTitleColor(_:for:) because buttons can have different UIControlState : . normal , .


2 Answers

The UIButton class exposes a titleLabel property, upon which you can change things like the font, the text color, etc.

like image 183
Justin Spahr-Summers Avatar answered Oct 03 '22 01:10

Justin Spahr-Summers


Set the font of the button's titleLabel:

myButton.titleLabel.font = [UIFont fontWithName:@"Courier" size:22.0]; 
like image 30
Darren Avatar answered Oct 03 '22 00:10

Darren