gpt4 book ai didi

ios - 更改 UITextView 字体大小

转载 作者:行者123 更新时间:2023-11-28 19:25:03 25 4
gpt4 key购买 nike

我无法更改 UITextViewfontSize,即使我设置了 .isSelectable=false

下面的代码无效。 fontSize 不可编辑。

    let linkLabel: UITextView = {
let v = UITextView()
v.backgroundColor = .clear
v.text = "Link"
v.textColor = .lightGray
v.font = UIFont(name: "AvenirNext", size: 23)
v.textAlignment = .right
v.isSelectable = false
v.isScrollEnabled = false
v.frame = CGRect(x: 0, y: 0, width: 200, height: 100)
// v.attributedText = NSAttributedString(string: "", attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue])
v.translatesAutoresizingMaskIntoConstraints = false
return v
}()

最佳答案

您的字体大小没有任何影响,因为“AvenirNext”不存在。尝试:“AvenirNext-Regular”

 let linkLabel: UITextView = {
let v = UITextView()
v.backgroundColor = .clear
v.text = "Link"
v.textColor = .lightGray
v.font = UIFont(name: "AvenirNext-Regular", size: 23)
v.textAlignment = .right
v.isSelectable = false
v.isScrollEnabled = false
v.frame = CGRect(x: 0, y: 0, width: 200, height: 100)
// v.attributedText = NSAttributedString(string: "", attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue])
v.translatesAutoresizingMaskIntoConstraints = false
return v
}()

这是获取 iOS 中包含的字体的正确字体名称的好资源

http://iosfonts.com

关于ios - 更改 UITextView 字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59760754/

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