UIButton * test=[[UIButton alloc] initWithFrame:CGRectMake(30, 30, 49, 49)];
test.buttonType= UIButtonTypeCustom;
- >使用“只读” **属性分配属性而不是允许
为什么呢?如何??
答案 0 :(得分:4)
您应该使用类方法
+ buttonWithType:
创建按钮。之后,设置框架。
<强>按钮类型强>
按钮类型。 (只读)
@property(nonatomic, readonly) UIButtonType buttonType
这意味着一旦按钮创建,您就无法更改buttonType
。
例如,您可以
UIButton *test = [UIButton buttonWithType:UIButtonTypeCustom];
test.frame = CGRectMake(30, 30, 49, 49);