Assigning "aspect fill" option for background image of uibutton Swift
<p>We can set the <strong>image</strong> of the button to be of aspect fill by :</p>

<pre><code>imageView?.contentMode = UIViewContentMode.ScaleAspectFill
</code></pre>

<p>but since I am dealing with the <strong>background</strong> image, I'm not sure how to access contentMode for the <strong>background</strong> image.</p>

<p>I know that instead of doing so, I can create a custom class where the image can be centered with the button text centered on top, then set the imageview as aspect fill with the above code, but that seems like a lot more work to achieve the same result.</p>

<p>What's the best way to accomplish this?</p>