如何使用@IBInspectable属性更改UIButton的大小?

时间:2016-12-21 10:37:50

标签: ios swift storyboard

我的UIButton课程:

@IBDesignable class AttributedButton: UIButton {

    @IBOutlet private var widthLayoutConstraint: NSLayoutConstraint?
    @IBInspectable override var isSelected: Bool {

        didSet {

            widthLayoutConstraint?.constant = isSelected ? 100 : 50
            borderColor = isSelected ? UIColor.lightGray : UIColor.white
        }
    }
}

然后当我在故事板中更改isSelected属性中的宽度时,它不起作用......为什么?

enter image description here

0 个答案:

没有答案