Use titleLabel
instead. The font
property is deprecated in iOS 3.0. It also does not work in Objective-C. titleLabel
is label used for showing title on UIButton
.
myButton.titleLabel?.font = UIFont(name: YourfontName, size: 20)
However, while setting title text you should only use setTitle:forControlState:
. Do not use titleLabel
to set any text for title directly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…