I have created the buttons using the loop and setting the properties and synthesize the buttons. Now i want to change the button color in the another view controller. I am setting the tag values for each button and i can get the tag values properly in another view controller, when select the buttons. Now i want to change the background color of each buttons.
Here it's sample code,
In CustomView.h
UIButton *customBtn;
property (nonatomic, strong) UIButton *customBtn;
@synthesize customBtn;
In CustomView.m
for (int i=0; i<=[resultArray count]; i++)
{
customBtn= [UIButton buttonWithType:UIButtonTypeCustom];
customBtn = CGRectMake(X, 30, 20, 20); notsupport = [[UILabel alloc]initWithFrame:CGRectMake(25, 30, 290, 20)];
[customBtn addTarget:customDelegate actionselector(MyAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:customBtn];
X = X + 30;
}
In View controller:
viewController.customBtn.backgroundColor = [UIColor blackColor];
It does affects all the buttons background color, so how can i change the background color of each buttons. If i am creating seperate instance for all the buttons and i can change the background color for the buttons. Using single instance of the buttons, how can we change the color of the button background.
Please Help me out.
Thanks!