How to override UIButton's init with button type in Swift?
<p>I want to subclass <code>UIButton</code> and add to it a property <code>isActive</code>, which is a <code>Bool</code> that changes the look of the button (this is not related to the default <code>.enabled</code> property). </p>

<p>However, I also want to set the button type when initialized. Specifically, I want to initialize it much like it is in <code>UIButton</code>, like:</p>

<pre><code>let button = MyButton(type: .Custom)
</code></pre>

<p>However, because the <code>.buttonType</code> is a read-only, I cannot just override it like:</p>

<pre><code>convenience init(type buttonType: UIButtonType) {
    buttonType = buttonType
    self.init()
}
</code></pre>

<p>This spits out an error: <code>Cannot assign to value: 'buttonType' is a 'let' constant</code> (I already implemented the required <code>init(coder:)</code>).</p>

<p>So how can I set the <code>.buttonType</code> when initialized?</p>

<hr>

<p>NOTE: The custom property shall be also used in other functions to change the logic within it, so I picked up a property, instead of defining two functions to change the look. </p>