UIBUTTON

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

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

TableViewCustomCell.h

[objc]
@property (weak, nonatomic) IBOutlet UIButton *button; @end
[/objc]

 

TableViewCustomCell.m

ボタン押下

[objc]
<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;
}
}
[/objc]

ON OFF 背景画像切り替え

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