我正在为拼图匹配游戏编写代码。我使用UIButton
定义了UIImage
,我添加了一个目标来更改UIImage
的{{1}}。
我希望这张照片一直显示,直到我点击另一个UIButton
或同一UIButton
,我该怎么做?!
UIButton
UIButton
然后方法:
mybutton1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[mybutton1 addTarget:self
action:@selector(method:)
forControlEvents:UIControlEventTouchDown];
question = [UIImage imageNamed:@"puzzle.jpg"];
[mybutton1 setBackgroundImage:question
forState:UIControlStateNormal];
答案 0 :(得分:0)
试试这种方式..
Button* mybutton1= [UIButton buttonWithType:UIButtonTypeCustom];
[mybutton1 addTarget:self
action:@selector(method:)
forControlEvents:UIControlEventTouchDown];
question = [UIImage imageNamed:@"puzzle.jpg"];
[mybutton1 setBackgroundImage:question
forState:UIControlStateNormal];
-(void) method: (UIButton*) sender{
[sender setBackgroundImage:[UIImage imageNamed: @"cheerful-cat.jpg"]
forState:UIControlStateNormal];
}