开发者

Custom UISlider Image disappearing?

Hello all i have a custom image to replace the UISLider defult button image, all works fine image shows, it does not clip off. The problem is when i use the slider to move up and down the image dissapears and some how doesnt show up anymore only sometimes. could someone have a fix?

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 imageNa开发者_StackOverflow社区med:@"SliderRight.png"];
[slider setMaximumTrackImage:rightImage forState:UIControlStateNormal];


I believe you need to set the highlighted state image as well:

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


In Swift -

customSlider.setThumbImage(#imageLiteral(resourceName: "slider_icon"), for: .normal)
customSlider.setThumbImage(#imageLiteral(resourceName: "slider_icon"), for: .highlighted)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜