Can't change the text size in programmatically created UILabel
<p>I cannot change the size of the text in a programmatically created <code>UILabel</code>.</p>

<p>Here's a screen grab:</p>

<p><a href="https://i.stack.imgur.com/hYka5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hYka5.jpg" alt="screen grab"></a></p>

<p>Here's the class definition:</p>

<pre><code>class myView: UIView {
    let theLabel = UILabel()

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.theLabel.text = "Text"
        self.theLabel.backgroundColor = UIColor.lightGray
        self.backgroundColor = UIColor.blue

        self.theLabel.adjustsFontSizeToFitWidth = true
        self.theLabel.textAlignment = .center
        self.theLabel.numberOfLines = 1
        self.theLabel.minimumScaleFactor = 0.1
        self.theLabel.font = UIFont( name: "System", size:160)
        self.theLabel.translatesAutoresizingMaskIntoConstraints = false
        self.addSubview(self.theLabel)

        let selfAspectConstraint = NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.width, multiplier: 1.0, constant: 0)

        let labelWidthConstraint = NSLayoutConstraint(item: self.theLabel, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.width, multiplier: 0.5, constant: 0)

        let heightConstraint = NSLayoutConstraint(item: self.theLabel, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: self.theLabel, attribute: NSLayoutAttribute.width, multiplier: 0.5, constant: 0)

        let xConstraint = NSLayoutConstraint(item: self.theLabel, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0)

        let yConstraint = NSLayoutConstraint(item: self.theLabel, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0)

        self.addConstraints([selfAspectConstraint,labelWidthConstraint, heightConstraint,xConstraint,yConstraint])
    }
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
}
</code></pre>

<p>I've tried changing the font size. I've set <code>adjustsFontSizeToFitWidth</code> to true and set <code>minimumScaleFactor</code>. The text size is always the same. I expect it to fill the label area, the grey box.</p>

<p>How do I get this to work?</p>