我已經使用下面的代碼動態創建了具有圖像的UISlider,但生成的UI僅顯示默認的UISlider。請任何人告訴我,爲什麼圖像沒有顯示在滑塊上。 (UISlider加載到也是動態創建的UIView類上)動態UISlider - 圖像未顯示
self.slider = [[UISlider alloc] initWithFrame:CGRectMake(40.0, 0.0, self.frame.size.width * 80.0/100.0, frame.size.height)];
self.slider.minimumValue = minValue;
self.slider.maximumValue = maxValue;
self.slider.backgroundColor = [UIColor clearColor];
[self.slider setThumbImage:[UIImage imageNamed:@"slider_tab.png"]
forState:UIControlStateNormal];
[self.slider setThumbImage:[UIImage imageNamed:@"slider_tab.png"]
forState:UIControlStateHighlighted];
[self.slider setMinimumTrackImage:[UIImage imageNamed:@"slider_minimum.png"]
forState:UIControlStateNormal];
[self.slider setMaximumTrackImage:[UIImage imageNamed:@"slider_maximum.png"]
forState:UIControlStateNormal];
self.slider.continuous = NO;
[self.slider addTarget:self action:@selector(SliderChanged:) forControlEvents:UIControlEventValueChanged];
[self addSubview:self.slider];
在此先感謝。
一旦檢查您的IBOutlet連接。 – Balu
你有解決方案嗎? – SRI
仍然沒有找到解決方案...我檢查了圖像名稱,它是正確的 – Karuthedan