Reputation: 243
UIButton * test=[[UIButton alloc] initWithFrame:CGRectMake(30, 30, 49, 49)];
test.buttonType= UIButtonTypeCustom;
-> assinging to property with 'readonly' **attribute not a allow
why? how??
Upvotes: 1
Views: 1397
Reputation: 48398
You should use the class method
+ buttonWithType:
to create the button. After that, set the frame.
From the UIButton Class Reference:
buttonType
The button type. (read-only)
@property(nonatomic, readonly) UIButtonType buttonType
This means that you cannot change the buttonType
once the button as been created.
For example, you can do
UIButton *test = [UIButton buttonWithType:UIButtonTypeCustom];
test.frame = CGRectMake(30, 30, 49, 49);
Upvotes: 4