With this simple code, I was assuming that getting "Hello World!"
to automatically shrink would work with bannerLabel.adjustsFontSizeToFitWidth
but the end of the text is clipped with ...
How do you get it to work properly?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With