Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在Swift中的初始值设定项中设置UIButton buttonType_Swift - Fatal编程技术网

无法在Swift中的初始值设定项中设置UIButton buttonType

无法在Swift中的初始值设定项中设置UIButton buttonType,swift,Swift,我想在Swift中对UIButton进行子类化。设置buttonType class MyButton: UIButton { init(label: KeyLabelType) { super.init(frame: CGRectZero) self.buttonType = UIButtonType.Custom } } 关于这一点不正确的原因有什么建议吗?苹果的文档说buttonType是一个只读属性。你必须为此找到一个解决办法。可能

我想在Swift中对UIButton进行子类化。设置
buttonType

class MyButton: UIButton {

    init(label: KeyLabelType) {

        super.init(frame: CGRectZero)

        self.buttonType = UIButtonType.Custom
    }
}

关于这一点不正确的原因有什么建议吗?

苹果的文档说
buttonType
是一个只读属性。你必须为此找到一个解决办法。可能会给你你想要的