swift – 如何让.adjustsFontSizeToFitWidth正常运行
发布时间:2020-12-14 04:42:10 所属栏目:百科 来源:网络整理
导读:有了这个简单的代码,我假设得到了“Hello World
有了这个简单的代码,我假设得到了“Hello World!”自动收缩将使用bannerLabel.adjustsFontSizeToFitWidth,但文本的末尾被剪切…如何让它正常工作?
import UIKit class ViewController: UIViewController,UIGestureRecognizerDelegate { @IBOutlet weak var bannerLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() bannerLabel.adjustsFontSizeToFitWidth = true bannerLabel.numberOfLines = 1 bannerLabel.text = "Hello World!" bannerLabel.font = UIFont(name: bannerLabel.font.fontName,size: 150)! } 解决方法titleLabel?.numberOfLines = 1 titleLabel?.adjustsFontSizeToFitWidth = true titleLabel?minimumScaleFactor = 0.1 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |