Iphone 在ios中使用UIButtonTypeCustom选项初始化

Iphone 在ios中使用UIButtonTypeCustom选项初始化,iphone,ios,uibutton,Iphone,Ios,Uibutton,->使用“readonly”辅助属性**属性不允许 为什么??如何使用class方法 UIButton * test=[[UIButton alloc] initWithFrame:CGRectMake(30, 30, 49, 49)]; test.buttonType= UIButtonTypeCustom; 创建按钮。然后,设置框架 从: 按钮类型 按钮类型。(只读) @属性(非原子,只读)UIButtonType buttonType 这意味着您不能在创建按钮后更改按钮类型 例如,你可

->使用“readonly”辅助属性**属性不允许


为什么??如何使用class方法

UIButton * test=[[UIButton alloc] initWithFrame:CGRectMake(30, 30, 49, 49)];

test.buttonType= UIButtonTypeCustom;
创建按钮。然后,设置框架

从:

按钮类型

按钮类型。(只读)

@属性(非原子,只读)UIButtonType buttonType

这意味着您不能在创建按钮后更改按钮类型

例如,你可以

+ buttonWithType:

您应该使用class方法

UIButton * test=[[UIButton alloc] initWithFrame:CGRectMake(30, 30, 49, 49)];

test.buttonType= UIButtonTypeCustom;
创建按钮。然后,设置框架

从:

按钮类型

按钮类型。(只读)

@属性(非原子,只读)UIButtonType buttonType

这意味着您不能在创建按钮后更改按钮类型

例如,你可以

+ buttonWithType: