我正在更改按鈕單擊上的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