@IBInspectable与enum? [英] @IBInspectable with enum?
问题描述
我想创建 @IBInspectable
元素,如下图所示:
I'd like to create @IBInspectable
element as you see at the picture below :
我的想法是使用像enum作为 @IBInspectable
的类型,但看起来并非如此,任何想法如何实现这样的元素?
my idea is to use something like enum as type for @IBInspectable
, but it looks like it's not the case, any ideas how to implement element like this ?
编辑:
看起来像 @IBInspectable
仅支持以下类型:
It looks like @IBInspectable
supports only these types :
-
Int
-
CGFloat
-
Double
-
String
-
Bool
-
CGPoint
-
CGSize
-
CGRect
-
UIColor
-
UIImage
Int
CGFloat
Double
String
Bool
CGPoint
CGSize
CGRect
UIColor
UIImage
bummer
推荐答案
这是不可能的(暂时)。您只能使用在用户定义的运行时属性部分中看到的那些类型。
That's not possible (for now). You can only use those types that you see in User Defined Runtime Attributes section.
来自Apple的 doc :
您可以将IBInspectable属性附加到类声明,类扩展或类别中的任何属性,以用于Interface Builder定义的运行时属性支持的任何类型:布尔值,整数或浮点数,字符串,本地化字符串,矩形,点,大小,颜色,范围和零。
You can attach the IBInspectable attribute to any property in a class declaration, class extension, or category for any type that’s supported by the Interface Builder defined runtime attributes: boolean, integer or floating point number, string, localized string, rectangle, point, size, color, range, and nil.
这篇关于@IBInspectable与enum?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!