iOS UIButton Getting the title label

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


The underlying title label, if one exists, can be fetched using


var label: UILabel? = button.titleLabel

Objective C

UILabel *label = button.titleLabel;

This can be used to set the font of the title label, for example


button.titleLabel?.font = UIFont.boldSystemFontOfSize(12)

Objective C

button.titleLabel.font = [UIFont boldSystemFontOfSize:12];

Got any iOS Question?