我正在为益智匹配游戏编写代码。我用 a 定义了 a UIButton
,UIImage
我添加了一个目标来改变UIImage
a 的 a 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];
然后方法:
-(void) method: (UIButton*) sender{
[sender setBackgroundImage:[UIImage imageNamed: @"cheerful-cat.jpg"]
forState:UIControlStateNormal];
}