我需要通过编程方式设置UIButton标题UILabel的字体大小。


当前回答

你可以使用:

button.titleLabel.font = [UIFont systemFontOfSize:14.0];

其他回答

这可能会有帮助:

[objBtn.titleLabel setFont:[UIFont fontWithName:@“fontname” size:fontsize]];

斯威夫特5。

uiButton.titleLabel?.font = UIFont.systemFont(ofSize: 32)

您还可以自定义按钮字体粗体,斜体。 本例采用系统粗体字体大小。

[LoginButton.titleLabel setFont:[UIFont boldSystemFontOfSize:15.0f*Ratio]];
button.titleLabel.font = [UIFont systemFontOfSize:size];

应该帮助

button.titleLabel.font = <whatever font you want>

对于那些想知道为什么他们的短信不显示的人,如果你这样做了

button.titleLabel.text = @"something";

它不会显示,你需要做:

[button setTitle:@"My title" forState:UIControlStateNormal]; //or whatever you want the control state to be