http://www.cocoachina.com/bbs/read.php?tid-48666-keyword-UIButton.html
初始设置:
UIImage *bgImg1 = [UIImage imageNamed:@"Selected.png"];
UIImage *bgImg2 = [UIImage imageNamed:@"Unselected.png"];
[btn setImage:bgImg2 forState:UIControlStateNormal];
[btn setImage:bgImg1 forState:UIControlStateSelected];
然后在button的Action方法改变button状态:
- (IBAction) buttonTouch:(id)sender
{
UIButton *button = (UIButton *)sender;
button.selected = !button.selected;
}