4

When you add @IBInspectable properties, they are initialized to essentially... nothing.

enter image description here

Is there a way to have these properties default to something? Say a red color for the track color, grey color for the background color and 10.0 for padding? I've tried @IBInspectable public var padding: CGFloat = 10.0 but the "10" does not get reflected in IB.

4

1 回答 1

2

试试这个代码:

override func prepareForInterfaceBuilder() {
    if self.padding == 0 {
        self.padding = 10}

}

来源http://justabeech.com/

于 2014-11-24T12:34:34.663 回答