Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自定义UIButton类,并在具有枚举的情节提要中显示它_Ios_Uibutton_Customization - Fatal编程技术网

Ios 自定义UIButton类,并在具有枚举的情节提要中显示它

Ios 自定义UIButton类,并在具有枚举的情节提要中显示它,ios,uibutton,customization,Ios,Uibutton,Customization,我想创建UIButton的子类。我想在那里提供一些额外的功能。在这个类中,我使用的枚举与UIButton类中的UIButtonType类似。我还想在storyboad UI中显示此选项,开发人员可以从中选择自定义按钮类的类型。请建议我,我如何才能做到这一点 您需要将UIButton继承的类指定为IBDesignable,并添加一个NSInteger IBInspectable属性,该属性将由InterfaceBuilder分析以便显示 但是,接口生成器无法呈现枚举类型IBInspectable属

我想创建UIButton的子类。我想在那里提供一些额外的功能。在这个类中,我使用的枚举与UIButton类中的UIButtonType类似。我还想在storyboad UI中显示此选项,开发人员可以从中选择自定义按钮类的类型。请建议我,我如何才能做到这一点

您需要将UIButton继承的类指定为IBDesignable,并添加一个NSInteger IBInspectable属性,该属性将由InterfaceBuilder分析以便显示

但是,接口生成器无法呈现枚举类型IBInspectable属性;这就是为什么实现这一点的唯一方法是NSInteger属性

最后,您将在interface builder中为自定义按钮(0,1…YourEnumMaxValue)选择一个与枚举值对应的整数值。最后,您只需要实现一些代码,以按照IB中的choosen值呈现按钮


更多关于LiveRendering的信息:

非常感谢您宝贵的回复。