使用这个简单的代码,我假设让"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)!
}
答案 0 :(得分:6)
titleLabel?.numberOfLines = 1
titleLabel?.adjustsFontSizeToFitWidth = true
titleLabel?minimumScaleFactor = 0.1