@IBInspectable with enum?

前端 未结 7 1376
旧时难觅i
旧时难觅i 2020-12-24 04:11

I\'d like to create @IBInspectable element as you see at the picture below :

\"enter

7条回答
  •  爱一瞬间的悲伤
    2020-12-24 04:57

    As @sikhapol answered, this is not possible. The workaround I use for this is to have a bunch of IBInspectable bools in my class and just select one in interface builder. For added security that multiple ones are not set, add an NSAssert in the setter for each one.

    - (void)setSomeBool:(BOOL)flag
    {
        if (flag)
        {
            NSAssert(!_someOtherFlag && !_someThirdFlag, @"Only one flag can be set");
        }
    }
    

    This is a little tedious and a bit sloppy IMO, but it's the only way to accomplish this kind of behavior that I can think of

提交回复
热议问题