Thursday, August 25, 2011

Dynamic button and Event on them ( Retro)

- (IBAction)Can:(id)sender {

i++;

UIButton *button2;
//view did load

// for( i= 1;i<=5;i++)

{
button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 addTarget:self action:@selector(ratingAction:)forControlEvents:UIControlEventTouchUpInside];
[button2 setBackgroundImage:[UIImage imageNamed:@"scanbutton1.png"] forState:UIControlStateNormal];
button2.tag = i;
button2.backgroundColor = [UIColor clearColor];
button2.frame = CGRectMake(20, width, 35, 35);
[self.view addSubview:button2];
width = width -38;
}



NSLog(@" i am can ");
// [self dismissModalViewControllerAnimated:YES];




}



-(void)ratingAction:(id*)sender
{

if ([sender isKindOfClass:[UIButton class]]) {


UIButton *temp=(UIButton*)sender;





if ([temp tag]==1 || [temp tag]==3 || [temp tag]==6 || [temp tag]==7 ) {

[temp setBackgroundColor:[UIColor redColor]];

}
}
}

No comments:

FEEDJIT Live