【发布时间】:2019-05-27 14:18:27
【问题描述】:
我使用以下代码为 uilabel 创建了自定义类:
@IBDesignable
public class CustomUILabel: UILabel {
public override func awakeFromNib() {
super.awakeFromNib()
configureLabel()
}
public override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
configureLabel()
}
func configureLabel() {
textColor = .white
font = UIFont(name: Constants.regularFontName, size: 14)
}
}
这有助于我在整个应用程序中设置字体。但我想为标题创建不同的粗体字体类型和为副标题创建常规字体。 这只能用一个文件吗? 或者我需要为该类型的 UIlabel 创建不同的扩展
【问题讨论】:
标签: ios fonts uilabel ibdesignable