UISlider进度条两边有空隙的解决办法

播放器UISlider进度条两边有空隙的解决办法   (swift版写法点此处)

 1.重写UISlider的这个方法 

-(CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value {

rect.origin.x=rect.origin.x-10;

rect.size.width=rect.size.width+20;

return CGRectInset([superthumbRectForBounds:bounds trackRect:rect value:value],10,10);

2.还可以重写  

-(CGRect)trackRectForBounds:(CGRect)bounds {

bounds.origin.x=15;

bounds.origin.y=bounds.size.height/3;

bounds.size.height=bounds.size.height/5;

bounds.size.width=bounds.size.width-30;

returnbounds;

}

-(CGRect)minimumValueImageRectForBounds:(CGRect)bounds;

-(CGRect)maximumValueImageRectForBounds:(CGRect)bounds; 

你可能感兴趣的:(UISlider进度条两边有空隙的解决办法)