UIBUTTON

平成26年9月1日(月曜日)

XIB設定(button設定)
TYPE →CUSTOM
STATECONFIG→ SELECTED

TableViewCustomCell.h

@property (weak, nonatomic) IBOutlet UIButton *button; @end

 

TableViewCustomCell.m

ボタン押下

<pre>- (IBAction)press_button:(UIButton *)sender {

// _button.selected = true;
NSLog(@"press!!");
if (_button.selected == true) {
_button.selected = false;
} else if(_button.selected == false) {
_button.selected = true;
}
}

ON OFF 背景画像切り替え

- (void)awakeFromNib
{
// Initialization code
NSLog(@"press!!");
[self.button setImage:[UIImage imageNamed:@"5.png"] forState:UIControlStateNormal];
[self.button setImage:[UIImage imageNamed:@"3.png"] forState:UIControlStateSelected];
}