我想在 Swift 中子类化一个 UIButton。设置 buttonType
class MyButton: UIButton {
init(label: KeyLabelType) {
super.init(frame: CGRectZero)
self.buttonType = UIButtonType.Custom
}
}
关于为什么这是不正确的任何建议?
最佳答案
Apple 文档说 buttonType
是一个只读属性。您将必须为此找到解决方法。 This answer可能会给你你正在寻找的东西。
关于swift - 无法在 Swift 的初始化程序中设置 UIButton buttonType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24106841/