對於UIButton在視圖之一,我創建了一個圖像用於正常狀態,但我想繼續使用默認的藍色/圖像的突出顯示/選擇狀態, 有沒有辦法做到這一點?或者我是否真的必須爲突出顯示/選擇準備定製圖像?UIButton定製使用標準的圖像/顏色爲突出顯示的狀態
下面是我每@mashios要求和意見有如下的代碼 -
UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
[shareButton setFrame:CGRectMake(1.0, 0.0, 99.0, 43.0)];
[shareButton setBackgroundImage:[[UIImage imageNamed:@"share_normal"]
stretchableImageWithLeftCapWidth:0.0
topCapHeight:0.0] forState:UIControlStateNormal];
[shareButton setBackgroundImage:[[UIImage imageNamed:@"share_normal"] // bottom_up_left_3_selected
stretchableImageWithLeftCapWidth:0.0
topCapHeight:0.0] forState:UIControlStateHighlighted];
[shareButton addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
我剛剛試驗過,通過將相同的圖像(用於正常狀態)設置爲突出顯示的狀態。結果不是我想要的,而是點擊按鈕時根本沒有顏色變化。 – tom 2012-01-09 18:24:49
你可以只提供一些代碼。 – mashios 2012-01-10 04:48:16
請查看我的帖子,上面有我使用的代碼 – tom 2012-01-10 09:29:06