我有两个按钮 Btn1 和 Btn2,上面有图像 Btn1image1.png,Btn2image1.png。通过单击每个按钮,它必须分别显示 Btn1image2.png 和 Btn2image2.png。
此外,如果单击 Btn1,则 Btn2 图像应该相同(Btn2image1.png)并且即
如何做到这一点?
我在这里添加我的工作,但在 Btn2 click 的情况下它不起作用
-(IBAction)Bt1Click:(id)sender
{
if (Bt1.selected=YES)
{
UIImage *buttonImage = [UIImage imageNamed:@"Btn1image2.png"];
[foodButt setBackgroundImage:buttonImage forState:UIControlStateSelected];
}
else
{
UIImage *buttonImage = [UIImage imageNamed:@"Btn2image1.png"];
[foodButt setBackgroundImage:buttonImage forState:UIControlStateNormal];
}
[self.searchBaar resignFirstResponder];
}
-(IBAction)Btn2Click:(id)sender
{
if (Btn2.selected=YES)
{
UIImage *buttonImage = [UIImage imageNamed:@"Btn2image2.png"];
[PeopButt setBackgroundImage:buttonImage forState:UIControlStateSelected];
}
else
{
UIImage *buttonImage = [UIImage imageNamed:@"Btn1image1.png"];
[PeopButt setBackgroundImage:buttonImage forState:UIControlStateNormal];
}
[self.searchBaar resignFirstResponder];
}