我希望限制组件现有类的某些属性。
以下是示例代码:
UIButton *customBtn;
property (nonatomic, strong) UIButton *customBtn;
@synthesize customBtn;
这是我的实现:
customBtn= [UIButton buttonWithType:UIButtonTypeCustom];
customBtn= setImage:[UIImage imageNamed"radio_button_noraml.png"] forState:UIControlStateNormal];
customBtn= setImage:[UIImage imageNamed"radio_button_acitve.png"] forState:UIControlStateSelected];
customBtn = CGRectMake(5, 30, 20, 20); notsupport = [[UILabel alloc]initWithFrame:CGRectMake(25, 30, 290, 20)];
[customBtn addTargetelf actionselector(MyAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:customBtn];
在我的视图控制器中,我可以使用customBtn访问UIbutton中的所有属性。
myClass.customBtn.backGroundcolor = [UIColor blackColor];
但是我希望限制对按钮属性的访问。例如,我只想访问property background color和alpha value,而不想访问其余属性。
请帮助我解决这个问题。
谢谢!