我正在更改按钮单击上的UIButton图像,但它获取位置从原始更改为左侧。我不知道为什么会发生这种情况。 下面是按钮。当我选择第二个按钮时,它会改变图像并到达左侧。我如何解决这个错误?更改UIButton图像获取按钮位置已更改
下面是我的代码
-(IBAction)locationOneButtonAction{
UIImage *buttonImage = [UIImage imageNamed:@"radiogreen.png"];
UIImage *buttonImageOne=[UIImage imageNamed:@"radiowhite.png"];
[locationOneButton setImage:buttonImage forState:UIControlStateNormal];
[locationOneButton setImage:buttonImage forState:UIControlStateNormal];
[locationThreeButton setImage:buttonImageOne forState:UIControlStateNormal];
[locationTwoButton setImage:buttonImageOne forState:UIControlStateNormal];
[locationFourButton setImage:buttonImageOne forState:UIControlStateNormal];
[locationFiveButton setImage:buttonImageOne forState:UIControlStateNormal];
[locationSixButton setImage:buttonImageOne forState:UIControlStateNormal];
[email protected]"Common Man - Bedford, MA";
}
您的图片尺寸可能不尽相同 – Eric
@Eric是的,你是对的,它们的尺寸不一样 – MRafiq
在那种情况下,为什么图像似乎移动? – Eric