An attempt to subclass UIButton, but an error occurs Must call a designated initializer of the superclass 'UIButton'.
Studying a few SO posts like this , this , this, or a few others did not help, as these solutions did not work.
How can we subclass UIButtonin Swift and define a custom init function?
import UIKit
class KeyboardButton : UIButton {
var letter = ""
var viewController:CustomViewController?
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(letter: String, viewController: CustomViewController) {
super.init()
...
}
}
source
share