I am trying to subclass a UIButton
so that its default initilizer sets it up the same way it would if you called UIButton(type: UIButtonType.roundedRect)
. However, I am unable to due to some Swift restrictions saying that that is not a designated initilizer. Additionally the buttonType
property is read only.
How can I do this in Swift?
For reference this code does not compile because I do not call a designated initializer.
class ToggleButton : UIButton {
init() {
super.init(type: UIButtonType.roundedRect)
}
required init?(coder aDecoder: NSCoder) {
fatalError("TROUBLE")
}
}