2010-04-14 74 views
0

你好,我有一個自定義圖像,以取代UISLider defult按鈕圖像,所有工作良好的圖像顯示,它不剪輯。問題是,當我使用滑塊上下移動圖像消失,並且有些時候不再出現。有人可以修復嗎?自定義UISlider圖像消失了嗎?

CGRect rect = CGRectMake(16.0, 390.0, 297.0, 35.0); 
slider.frame = rect; 

UIImage* thumbImage = [UIImage imageNamed:@"thumb.png"]; 
[slider setThumbImage:thumbImage forState:UIControlStateNormal]; 

UIImage* leftImage = [UIImage imageNamed:@"SliderLeft.png"]; 
[slider setMinimumTrackImage:leftImage forState:UIControlStateNormal]; 

UIImage* rightImage = [UIImage imageNamed:@"SliderRight.png"]; 
[slider setMaximumTrackImage:rightImage forState:UIControlStateNormal]; 
+0

你可以發佈一個代碼示例? – 2010-04-14 21:03:27

回答

14

我相信你需要設置高亮顯示狀態的圖像,以及:

[slider setThumbImage:thumb forState:UIControlStateNormal];  
[slider setThumbImage:thumb forState:UIControlStateHighlighted]; 
+0

@michap,我該怎麼感謝你? 我嘗試了這麼多東西,沒有任何工作!然後我離開了一個月,回來了,研究並發現你的智慧:)謝謝! – 2011-06-20 08:48:25