Aspect fit in cgsize programmatically in swift : <p><a href="https://i.stack.imgur.com/leswD.png" rel="nofollow noreferrer">Click here for image.</a></p>

<p>Need help fitting label so that the left and right side fills. 
Code is at the bottom.</p>

<pre><code>  @IBOutlet weak var header: UILabel!

override func viewDidLoad() {
    header.adjustsFontSizeToFitWidth = true

    let rectShape = CAShapeLayer()
    rectShape.bounds = self.header.frame
    rectShape.position = self.header.center
    rectShape.path = UIBezierPath(roundedRect: self.header.bounds, byRoundingCorners: [.bottomLeft , .bottomRight], cornerRadii: CGSize(width:300, height: 200)).cgPath

    self.header.layer.backgroundColor = UIColor.green.cgColor
    //Here I'm masking the textView's layer with rectShape layer
    self.header.layer.mask = rectShape


    super.viewDidLoad()
</code></pre>
