2011-04-27 124 views

回答

13
[yourButton setImage:[UIImage imageNamed:@"yourNormalImage.png"] forState:UIControlStateNormal]; 
[yourButton setImage:[UIImage imageNamed:@"yourImageWhenClicking.png"] forState:UIControlStateHighlighted]; 

把你clickEvent圖像作爲按鈕的突出顯示的圖像..

+0

我的背景圖像被用下面的代碼發生變化:[cell.ansBtn2 setImage:[UIImage的imageNamed:@ 「option_red.png」] forState:UIControlStateSelected];但我想在兩個按鈕這個變化。然後我想重置按鈕與先前的圖像..... – 2011-04-28 06:29:53

+0

如果你想這個改變這第二個按鈕也把相同的代碼那裏[yourSecondButton setImage:[UIImage imageNamed:@「 yourNormalImage.png「] forState:UIControlStateNormal];你的SelectorButton setImage:[UIImage imageNamed:@「yourImageWhenClicking.png」] forState:UIControlStateHighlighted]; – Krishnabhadra 2011-04-28 06:50:00

6

以上回答是行不通的,因爲它不會改變的背景,但UIButton的側面形象,更改背景圖片使用:

[yourButton setBackgroundImage:[UIImage imageNamed:@"yourimage"] forState:UIControlStateNormal]; 
相關問題