How to set default values for IBInspectable in Objective-C?

前端 未结 5 997
面向向阳花
面向向阳花 2021-01-30 16:15

I know default values of IBInspectable-properties can be set as:

@IBInspectable var propertyName:propertyType = defaultValue in Swift. But how do I achieve

5条回答
  •  无人共我
    2021-01-30 16:29

    I'm using like that

    @IBInspectable var propertyNameValue:propertyType?
    var propertyName:propertyType { return propertyNameValue ?? defaultValue }
    

    if propertyNameValue has nil, propertyName will return defaultValue.

提交回复
热议问题