且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Swift默认UILabel字体和大小

更新时间:2023-01-27 20:39:53

首先你需要为UILabel添加扩展名:

First you need to add extension to UILabel :

extension UILabel{
    var defaultFont: UIFont? {
        get { return self.font }
        set { self.font = newValue }
    }
}

第二次使用外观进行设置:

Second use appearance to set it:

    UILabel.appearance().defaultFont = UIFont.systemFont(ofSize: 25)

希望有所帮助。