I try to make an horizontal navigation menu in scrollView. For every items in the menu i had a different image. When i select an item, i would like to change background image of this item, but i don't know why my code doesn't work:
for (int i=0; i<12; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *normal=[UIImage imageNamed:@"icon1"];
UIImage *selec=[UIImage imageNamed:@"icon1down"];
[btn setFrame:CGRectMake(i*larg, 0, 42.0, 43.0)];
[btn setBackgroundImage:normal forState:UIControlStateNormal];
[btn setBackgroundImage:selec forState:UIControlStateSelected];
[scrollCat addSubview:btn];
cx+=42.0;
}
[scrollCat setContentSize:CGSizeMake(cx, 43)];
Is there a bad thing in this code?