4

I want to subclass a UIButton in Swift. I get an error when setting buttonType

class MyButton: UIButton {

    init(label: KeyLabelType) {

        super.init(frame: CGRectZero)

        self.buttonType = UIButtonType.Custom
    }
}

Any suggestions on why this is incorrect?

David
  • 14,205
  • 20
  • 97
  • 144

1 Answers1

4

The apple docs say that buttonType is a readonly property. You will have to find a workaround for this. This answer might give you what you are looking for.

Community
  • 1
  • 1
67cherries
  • 6,931
  • 7
  • 35
  • 51