gpt4 book ai didi

ios swift UILabel 字体大小不会以编程方式更改

转载 作者:行者123 更新时间:2023-11-29 05:33:09 25 4
gpt4 key购买 nike

我想更改 UILabel 的字体大小,但它不会以编程方式更改。
当我更改文本颜色时,它会更改颜色

我尝试了很多事情,但没有成功

以下是我的代码

@IBOutlet weak var lblExample: UILabel!
override func viewDidLoad() {
super.viewDidLoad()

self.lblExample.font = UIFont(name: self.lblExample.font.fontName, size: 40)
//self.lblExample.font = UIFont.systemFont(ofSize: 40)
//self.lblExample.font = UIFont(name: "System", size: 40)
//self.lblExample.font = self.lblExample.font.withSize(40);

self.lblExample.textColor = UIColor.green
}

属性检查器属性

enter image description here

How to change font of UILabel
why is it not changing

最佳答案

并且没有改变?

let lab = UILabel(frame: ...)
lab.font = UIFont(name: "Helvetica Fett", size: 14)
lab.font = lab.font
lab.font = UIFont.systemFont(ofSize: 14)
lab.font = UIFont.systemFont(ofSize: 14, weight: .bold)
lab.text = "TEST"

关于ios swift UILabel 字体大小不会以编程方式更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57336254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com