UIButton的自定义字体标题

xyd*_*dev 24 iphone uibutton

有没有办法让自定义字体到按钮的标题.

Jus*_*ers 44

UIButton类公开titleLabel属性,在这你可以改变,如字体,文字颜色,等事情

  • 注意`titleLabel`的一些属性在`setTitle()`之后被重置. (10认同)
  • 不建议根据Apple的文档"不要使用标签对象设置文本颜色或阴影颜色来设置titleLable的textColor属性.而是使用setTitleColor:forState:和setTitleShadowColor:forState:此类的方法来制作那些变化." https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/#//apple_ref/occ/instp/UIButton/titleLabel (3认同)

Dar*_*ren 22

设置按钮的字体titleLabel:

myButton.titleLabel.font = [UIFont fontWithName:@"Courier" size:22.0];
Run Code Online (Sandbox Code Playgroud)