label.font.pointSize是只读的,所以我不确定如何更改它。


当前回答

我使用fontWithSize标签与轻系统字体,但它改变回正常的系统字体。

如果你想保持字体的特征,最好包括描述符。

标签。font = UIFont(descriptor: label.font.fontDescriptor(), size: 16.0)

其他回答

再次在Swift 3中…

myLabel.font = myLabel.font.withSize(18)

如果你想使用粗体自定义字体选项:

nameLabel.font = UIFont(name: "GillSans-Bold", size: 27)

我使用fontWithSize标签与轻系统字体,但它改变回正常的系统字体。

如果你想保持字体的特征,最好包括描述符。

标签。font = UIFont(descriptor: label.font.fontDescriptor(), size: 16.0)

在Swift 3中:

label = UIFont.systemFont(ofSize: 20)

并使用系统预设的大小,例如:

label = UIFont.systemFont(ofSize: UIFont.smallSystemFontSize)

斯威夫特3.1

标签。font = Label.font.withSize(新值)