无法在Swift的初始化程序中设置UIButton buttonType

时间:2014-06-08 13:55:26

标签: swift

我想在Swift中继承UIButton。设置buttonType

时出错
class MyButton: UIButton {

    init(label: KeyLabelType) {

        super.init(frame: CGRectZero)

        self.buttonType = UIButtonType.Custom
    }
}

有关为什么这不正确的任何建议?

1 个答案:

答案 0 :(得分:4)

苹果文档说buttonType是一个只读属性。您必须找到解决方法。 This answer可能会为您提供所需内容。